7 Replies Latest reply on Mar 15, 2011 10:51 AM by Che Schneider

    NoInitialContextException when deploying MDB on custom resource adapter

    Che Schneider Newbie

      Stackoverflow link is http://stackoverflow.com/questions/5089705/noinitialcontextexception-when-deploying-mdb-on-custom-resource-adapter

       

      Hi all,

       

       

      I've 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

      {code:xml}

          <?xml version="1.0"?>

          <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>

      {code}

       

       

      jboss.xml

      {code: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>

      {code}

       

       

      MyUpdateService

       

      {code}

          @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)

          public class EuronextUpdateService implements MulticastListener, MessageDrivenBean  {

             [snip]

          }

      {code}

       

       

      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:

       

      {code}

          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

      {code}

       

       

      Any ideas?

       

       

      Cheers,

      Che