在自定义资源适配器上部署 MDB 时出现 NoInitialContextException

发布于 2024-10-19 02:34:39 字数 5585 浏览 2 评论 0原文

我开发了一个资源适配器,我想在我的应用程序中使用它,部署在 JBoss 5.1 中。在研究了注释和 xml 文件之后,我提出了以下设置。

ejb-jar.xml

<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" version="3.0">
    <enterprise-beans>
        <message-driven>
            <display-name>MyUpdateService</display-name>
            <ejb-name>MyUpdateService</ejb-name>
            <ejb-class>com.my.package.MyUpdateService</ejb-class>
            <messaging-type>com.my.other.package.AdapterListener</messaging-type>
            <transaction-type>Bean</transaction-type>
        </message-driven>
    </enterprise-beans>
</ejb-jar>

jboss.xml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE jboss PUBLIC
          "-//JBoss//DTD JBOSS 4.0//EN"
          "http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">
<jboss>
    <enterprise-beans>
        <message-driven>
            <ejb-name>MyUpdateService</ejb-name>
            <activation-config>
                <activation-config-property>
                    <activation-config-property-name>parameter1</activation-config-property-name>
                    <activation-config-property-value>value1</activation-config-property-value>
                </activation-config-property>

                <activation-config-property>
                    <activation-config-property-name>parameter2</activation-config-property-name>
                    <activation-config-property-value>value2</activation-config-property-value>
                </activation-config-property>
            </activation-config>
            <resource-adapter-name>myear.ear#adaptor.rar</resource-adapter-name>
            <depends>jboss.jca:service=RARDeployment,name='myear.ear#adaptor.rar'</depends>
        </message-driven>
    </enterprise-beans>
</jboss>

MyUpdateService

@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public class EuronextUpdateService implements MulticastListener, MessageDrivenBean  {
   [snip]
}

我还尝试了大多数注释组合而不是 xml 文件,但是,我总是得到相同的结果: 所有 bean 都部署良好,MyUpdateService bean 也是如此。资源适配器确实向我的bean 发送消息,它可以很好地处理它。

虽然我可以像这样使用适配器,但我确实在我的日志中收到以下异常,我真的很想摆脱它:

2011-02-23 11:15:54,640 WARN  [org.jboss.resource.adapter.jms.inflow.JmsActivation] (WorkManager(2)-75) Failure in jms activation org.jboss.resource.adapter.jms.inflow.JmsActivationSpec@26af5ca9(ra=org.jboss.resource.adapter.jms.JmsResourceAdapter@157024fc destination=/topic/MyTopic destinationType=javax.jms.Topic tx=false ack=Auto-acknowledge durable=false reconnect=10 provider=java:/DefaultJMSProvider user=null maxMessages=1 minSession=1 maxSession=1 keepAlive=60000 useDLQ=true DLQHandler=org.jboss.resource.adapter.jms.inflow.dlq.GenericDLQHandler DLQJndiName=queue/DLQ DLQUser=null DLQMaxResent=0)
javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.IllegalStateException: BaseClassLoader@26780d3c{vfszip:/opt/jboss-5.1.0.GA/server/default/deploy/myear.ear/} classLoader is not connected to a domain (probably undeployed?) for class org.jnp.interfaces.NamingContextFactory]
        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
        at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
        at javax.naming.InitialContext.init(InitialContext.java:223)
        at javax.naming.InitialContext.<init>(InitialContext.java:175)
        at org.jboss.util.naming.Util.lookup(Util.java:179)
        at org.jboss.resource.adapter.jms.inflow.JmsActivation.setupJMSProviderAdapter(JmsActivation.java:397)
        at org.jboss.resource.adapter.jms.inflow.JmsActivation.setup(JmsActivation.java:346)
        at org.jboss.resource.adapter.jms.inflow.JmsActivation$SetupActivation.run(JmsActivation.java:729)
        at org.jboss.resource.work.WorkWrapper.execute(WorkWrapper.java:205)
        at org.jboss.util.threadpool.BasicTaskWrapper.run(BasicTaskWrapper.java:260)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.IllegalStateException: BaseClassLoader@26780d3c{vfszip:/opt/jboss-5.1.0.GA/server/default/deploy/myear.ear/} classLoader is not connected to a domain (probably undeployed?) for class org.jnp.interfaces.NamingContextFactory
        at org.jboss.classloader.spi.base.BaseClassLoader.loadClassFromDomain(BaseClassLoader.java:793)
        at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:441)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:247)
        at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:46)
        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
        ... 12 more

有什么想法吗?

干杯, 车

I developed a resource adapter that I would like to use within my application ear, deployed in JBoss 5.1. After playing around with annotations and xml files, I came up with the following setup.

ejb-jar.xml

<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" version="3.0">
    <enterprise-beans>
        <message-driven>
            <display-name>MyUpdateService</display-name>
            <ejb-name>MyUpdateService</ejb-name>
            <ejb-class>com.my.package.MyUpdateService</ejb-class>
            <messaging-type>com.my.other.package.AdapterListener</messaging-type>
            <transaction-type>Bean</transaction-type>
        </message-driven>
    </enterprise-beans>
</ejb-jar>

jboss.xml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE jboss PUBLIC
          "-//JBoss//DTD JBOSS 4.0//EN"
          "http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">
<jboss>
    <enterprise-beans>
        <message-driven>
            <ejb-name>MyUpdateService</ejb-name>
            <activation-config>
                <activation-config-property>
                    <activation-config-property-name>parameter1</activation-config-property-name>
                    <activation-config-property-value>value1</activation-config-property-value>
                </activation-config-property>

                <activation-config-property>
                    <activation-config-property-name>parameter2</activation-config-property-name>
                    <activation-config-property-value>value2</activation-config-property-value>
                </activation-config-property>
            </activation-config>
            <resource-adapter-name>myear.ear#adaptor.rar</resource-adapter-name>
            <depends>jboss.jca:service=RARDeployment,name='myear.ear#adaptor.rar'</depends>
        </message-driven>
    </enterprise-beans>
</jboss>

MyUpdateService

@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public class EuronextUpdateService implements MulticastListener, MessageDrivenBean  {
   [snip]
}

I also tried most combinations of annotations as opposed to xml files, however, I always get the same result:
All beans are deployed fine, also the MyUpdateService bean. The resource adapter does send messages to my bean, which can process it just fine.

While I can work with the adapter like this, I do get the following exception in my log, which I really would like to get rid of:

2011-02-23 11:15:54,640 WARN  [org.jboss.resource.adapter.jms.inflow.JmsActivation] (WorkManager(2)-75) Failure in jms activation org.jboss.resource.adapter.jms.inflow.JmsActivationSpec@26af5ca9(ra=org.jboss.resource.adapter.jms.JmsResourceAdapter@157024fc destination=/topic/MyTopic destinationType=javax.jms.Topic tx=false ack=Auto-acknowledge durable=false reconnect=10 provider=java:/DefaultJMSProvider user=null maxMessages=1 minSession=1 maxSession=1 keepAlive=60000 useDLQ=true DLQHandler=org.jboss.resource.adapter.jms.inflow.dlq.GenericDLQHandler DLQJndiName=queue/DLQ DLQUser=null DLQMaxResent=0)
javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.IllegalStateException: BaseClassLoader@26780d3c{vfszip:/opt/jboss-5.1.0.GA/server/default/deploy/myear.ear/} classLoader is not connected to a domain (probably undeployed?) for class org.jnp.interfaces.NamingContextFactory]
        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
        at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
        at javax.naming.InitialContext.init(InitialContext.java:223)
        at javax.naming.InitialContext.<init>(InitialContext.java:175)
        at org.jboss.util.naming.Util.lookup(Util.java:179)
        at org.jboss.resource.adapter.jms.inflow.JmsActivation.setupJMSProviderAdapter(JmsActivation.java:397)
        at org.jboss.resource.adapter.jms.inflow.JmsActivation.setup(JmsActivation.java:346)
        at org.jboss.resource.adapter.jms.inflow.JmsActivation$SetupActivation.run(JmsActivation.java:729)
        at org.jboss.resource.work.WorkWrapper.execute(WorkWrapper.java:205)
        at org.jboss.util.threadpool.BasicTaskWrapper.run(BasicTaskWrapper.java:260)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.IllegalStateException: BaseClassLoader@26780d3c{vfszip:/opt/jboss-5.1.0.GA/server/default/deploy/myear.ear/} classLoader is not connected to a domain (probably undeployed?) for class org.jnp.interfaces.NamingContextFactory
        at org.jboss.classloader.spi.base.BaseClassLoader.loadClassFromDomain(BaseClassLoader.java:793)
        at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:441)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:247)
        at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:46)
        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
        ... 12 more

Any ideas?

Cheers,
Che

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文