3 Replies Latest reply on Aug 13, 2007 7:30 PM by Atul Kshatriya

    javax.naming.NoInitialContextException trying to connect to

    Atul Kshatriya Newbie

      I have a simple setup where I am trying to connect to a remote JMS queue using a MDB. Jboss and JDK versions are Jboss 4.0.4GA and JDK 1.4.2_11 respectively. I have configured the MDB Jboss instance as well as the queue host where the JMSProvider is configured (the default JbossMQ provider) as per the JBoss documentation

      http://wiki.jboss.org/wiki/Wiki.jsp?page=HowDoIConfigureAnMDBToTalkToARemoteQueue

      But when I try to start the JBoss where the MDB is deployed I get this as JBoss is starting up. This exception comes during the deployment of the MDB. The MDB does get deployed properly but the server keeps retrying to connect to the remote JMS provider (default every 10 seconds) and this exception is repeated.


      javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org/jnp/interfaces/NamingContextFactory ]
      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:652)
      at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
      at javax.naming.InitialContext.init(InitialContext.java:219)
      at javax.naming.InitialContext.(InitialContext.java:195)
      at org.jboss.jms.jndi.JNDIProviderAdapter.getInitialContext(JNDIProviderAdapter.java:44)
      at org.jboss.ejb.plugins.jms.DLQHandler.createService(DLQHandler.java:177)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalCreate(ServiceMBeanSupport.java:260)
      at org.jboss.system.ServiceMBeanSupport.create(ServiceMBeanSupport.java:188)
      at org.jboss.ejb.plugins.jms.JMSContainerInvoker.innerStartDelivery(JMSContainerInvoker.java:510)
      at org.jboss.ejb.plugins.jms.JMSContainerInvoker.startService(JMSContainerInvoker.java:839)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
      at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)

      I would greatly appreciate if anybody has faced this issue and resolved it. If you can guide me as to where I may has a misconfiguration that would be great as well.


      The JMS provider is configured in the jms-ds.xml as follows -

      <!-- Configuration for a Remote JMS Provider to access to queue object on
      a remote machine through it's JNDI
      -->

      ABC-JMSProvider
      org.jboss.jms.jndi.JNDIProviderAdapter
      <!-- The queue connection factory -->
      XAConnectionFactory
      <!-- The topic factory -->
      XAConnectionFactory

      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      java.naming.factory.url.pkgs=org.jnp.interfaces
      java.naming.provider.url=ABCServer:1099




      The MDB configuration is as follows (jboss.xml) -


      <invoker-proxy-bindings>
      <invoker-proxy-binding>
      Abc-mdb-invoker
      <invoker-mbean>does-not-matter</invoker-mbean>
      <proxy-factory>org.jboss.ejb.plugins.jms.JMSContainerInvoker</proxy-factory>
      <proxy-factory-config>
      ABC-JMSProvider
      StdJMSPool
      1
      15
      30000
      1

      10

      queue/DLQ
      10
      0


      </proxy-factory-config>
      </invoker-proxy-binding>
      </invoker-proxy-bindings>
      <enterprise-beans>
      <message-driven>
      <ejb-name>TestMdb</ejb-name>
      <destination-jndi-name>queue/TestQueue</destination-jndi-name>
      <invoker-bindings>

      <invoker-proxy-binding-name>Abc-mdb-invoker</invoker-proxy-binding-name>

      </invoker-bindings>
      </message-driven>
      </enterprise-beans>




      Thanks in Advance.

        • 1. Re: javax.naming.NoInitialContextException trying to connect
          Gary Ratcliffe Newbie

          Hi,

          For remote JNDI access to the JBoss server we use the following:


          java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
          java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
          java.naming.provider.url=jnp://localhost:1099


          The java.naming.factory.url.pkgs setting is different to your example in that it includes org.jnp.interfaces and org.jboss.naming. I don't know if this is related since I have not used this for an MDB accessing a remote queue.

          Gary

          • 2. Re: javax.naming.NoInitialContextException trying to connect
            Atul Kshatriya Newbie

            Actually I tried putting that as well. But I am getting the same exception. I do have a similar other setup that does not give this problem. I am trying to find what is the difference between the two setups. The one that is giving the problem is from the jboss install archive without any changes to it.

            Will keep posted if i do find something. But if anybody has a similar issue would appreciate if they can give me some hints.

            Thanks.


            "GRatcliffe" wrote:
            Hi,

            For remote JNDI access to the JBoss server we use the following:


            java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
            java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
            java.naming.provider.url=jnp://localhost:1099


            The java.naming.factory.url.pkgs setting is different to your example in that it includes org.jnp.interfaces and org.jboss.naming. I don't know if this is related since I have not used this for an MDB accessing a remote queue.

            Gary


            • 3. Re: javax.naming.NoInitialContextException trying to connect
              Atul Kshatriya Newbie

              Okay - I have found the resolution and it is pretty simple but I think it would be important for people to know.

              The exception was being thrown because I did a cut paste of the block of the JMS provider from MS Word into vi editor on linux (found out it does not matter - even while editing on windows give same issue). That made tab characters remain in the block rather than spaces for the jndi context properties. That was causing the jndi lookup to fail. So the properties being loaded had those tab characters and they were not removed (?? don't know why - shouldn't white space removed/trimmed) during the lookup and obviously the name could not be found.

              Pretty silly mistake - but took quite a bit of time.