6 Replies Latest reply on Mar 10, 2009 12:49 PM by rakula

    Problem finding JMS ConnectionFactory from JNDI lookup in Jb

      Hi All,

      When i am trying to migrate my application from Jboss 4.0.1 to Jboss 5.0, Getting the following exception. It looks like problem finding JMS ConnectionFactory and destinations.

      [Mon Mar 09 13:52:13 PDT 2009][JDBC][com.generic.jmsprocessor.QReceiver][SYSTEM][main] javax.naming.NameNotFoundException: ConnectionFactory not bound
       at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
       at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
       at org.jnp.server.NamingServer.getObject(NamingServer.java:785)
       at org.jnp.server.NamingServer.listBindings(NamingServer.java:539)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
       at sun.rmi.transport.Transport$1.run(Transport.java:153)
       at java.security.AccessController.doPrivileged(Native Method)
       at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
       at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
       at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
       at java.lang.Thread.run(Thread.java:595)
      

      Exceprion from server console
      2009-03-09 13:52:13,228 INFO [STDOUT] (main) Got JMS context from JNDI javax.naming.InitialContext@df6bb8
      2009-03-09 13:52:13,259 DEBUG [org.jnp.interfaces.TimedSocketFactory] (main) createSocket, hostAddr: localhost/127.0.0.1, port: 1099, localAddr: null, localPort: 0, timeout: 0
      2009-03-09 13:52:13,353 INFO [STDOUT] (main) JNDI lookup failed: javax.naming.NameNotFoundException: ConnectionFactory not bound
      2009-03-09 13:52:13,369 INFO [STDOUT] (main) JNDI lookup failed: javax.naming.NameNotFoundException: ConnectionFactory not bound
      2009-03-09 13:52:13,369 INFO [STDOUT] (main) Connection problem: javax.naming.NameNotFoundException: ConnectionFactory not bound
      2009-03-09 13:52:13,369 INFO [STDOUT] (main) JNDI lookup failed: javax.naming.NameNotFoundException: ConnectionFactory not bound
      2009-03-09 13:52:13,369 INFO [STDOUT] (main) Connection problem: javax.naming.NameNotFoundException: ConnectionFactory not bound
      2009-03-09 13:52:13,400 INFO [STDOUT] (main) JNDI lookup failed: javax.naming.NameNotFoundException: epostrx not bound
      2009-03-09 13:52:13,400 INFO [STDOUT] (main) ERROR:: While creating publisher for topic java.lang.NullPointerException
      


      Destination configurations in *-service.xml
       <mbean code="org.jboss.jms.server.destination.TopicService"
       name="jboss.messaging.destination:service=Topic,name=epostrx"
       xmbean-dd="xmdesc/Topic-xmbean.xml">
       <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
       <depends>jboss.messaging:service=PostOffice</depends>
       </mbean>
      
      <mbean code="org.jboss.jms.server.destination.QueueService" name="jboss.messaging.destination:service=Queue,name=autocontact"
       xmbean-dd="xmdesc/Queue-xmbean.xml">
       <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
       <depends>jboss.messaging:service=PostOffice</depends>
       </mbean>


      I am using the default connection factory which is configured in connection-factories-service.xml

      
      <mbean code="org.jboss.jms.server.connectionfactory.ConnectionFactory"
       name="jboss.messaging.connectionfactory:service=ConnectionFactory"
       xmbean-dd="xmdesc/ConnectionFactory-xmbean.xml">
       <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
       <depends optional-attribute-name="Connector">jboss.messaging:service=Connector,transport=bisocket</depends>
       <depends>jboss.messaging:service=PostOffice</depends>
      
       <attribute name="JNDIBindings">
       <bindings>
       <binding>/ConnectionFactory</binding>
       <binding>/XAConnectionFactory</binding>
       <binding>java:/ConnectionFactory</binding>
       <binding>java:/XAConnectionFactory</binding>
       <binding>/QueueConnectionFactory</binding>
       <binding>/TopicConnectionFactory</binding>
       </bindings>
       </attribute>
       </mbean>
      


      When i look in the JMX console, i see that Connection factory and queues and topic registered sucessfully, but when the code is trying to look for a ConnectionFactory and queue, i am getting this exception.
      Can somebody please help me here.

      Thanks in Advance,
      Raj


        • 1. Re: Problem finding JMS ConnectionFactory from JNDI lookup i
          peterj

          The destination configuration looks correct, and you are saying that it appears that the queues and topics are being deployed. So the issue must be with the code doing the lookup; could you post that code? Also, indicate where the client code is running (standalone? within JBoss AS?)

          You could also check JNDIView to determine if the entries are really in JNDI.

          • 2. Re: Problem finding JMS ConnectionFactory from JNDI lookup i

            Hi Peter,

            Thanks for the quick reply.

            Here is the lookup code, the client code is running from with Jboss AS.

            Object obj = null;
            try {
            
             jndiContext = JNDIContextUtil.getJMSContext();
             } catch (Exception e) {
             System.out.println("Could not create JNDI context: " +
             e.toString());
             throw e;
             }
             }
            
            try {
            
             obj = jndiContext.lookup(name);
             } catch (NamingException e) {
             System.out.println("JNDI lookup failed: " + e.toString());
             throw e;
             }
            

            Getting JMS context
            Context ctx = null;
             try {
             Properties h = new Properties();
             h.put(Context.INITIAL_CONTEXT_FACTORY, Environment.jmsContext);
             h.put(Context.PROVIDER_URL, Environment.jmsUrl);
             h.put(Context.URL_PKG_PREFIXES, Environment.jmsPrefixes);
            
             ctx = new InitialContext(h);
             System.out.println("Got JMS context from JNDI " + ctx);
             } catch (NamingException ne) {
             throw new ServerNotReachableException(ne.toString());
             }
            

            Variables from Environment class
            public static String jmsContext = null;
             public static String jmsUrl = null;
             public static String jmsPrefixes = null;
            


            This code works fine in Jboss 4.0.1 AS.

            Thanks,
            Raj

            • 3. Re: Problem finding JMS ConnectionFactory from JNDI lookup i
              peterj

              The names of the objects you are looking up are hidden inside variables (such as 'name') or within methods (such as "getJmsContext()"), so this code does not help. I need to see literal stings.

              I also don't understand the JMS context lookup code - it appears that you are only looking up the initial context.

              • 4. Re: Problem finding JMS ConnectionFactory from JNDI lookup i

                There are the literal strings.
                jmsContext = org.jnp.interfaces.NamingContextFactory
                jmsUrl = localhost:1099
                jmsPrefixes = org.jboss.naming

                Also, JNDI view in JMX console does not show the entries for ConnectionFactory and destinations. What do i need to do to show up these in the JNDI view. It only shows HANamingService.

                Thanks,
                Raj

                • 5. Re: Problem finding JMS ConnectionFactory from JNDI lookup i
                  peterj

                  ALL of the strings, please. Such as 'name' in "obj = jndiContext.lookup(name);"

                  Are you running the 'all' configuration?

                  • 6. Re: Problem finding JMS ConnectionFactory from JNDI lookup i

                    I figured out the problem and resolved it. Now i don't get this error anymore and Jboss server started successfully.

                    The problem was with the PostOffice service, which is not deoployed correctly. As the destinations are dependent on PostOffice service, these destinations were not registered successfully. After making PostOffice service deployed, all the configured destinations registered successfully and i did not see JNDI lookup error while starting Jboss server.

                    I commented out unwanted configurations related to PostOffice service in *-persistence-service.xml to deploy PostOffice service successfully.

                    Thanks,
                    Raj