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

时间:2011-02-23 10:35:02

标签: java exception jboss5.x message-driven-bean initial-context

我开发了一个资源适配器,我希望在我的应用程序中使用,部署在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

有什么想法吗?

干杯, 澈

0 个答案:

没有答案