2 Replies Latest reply on Dec 19, 2007 6:23 AM by Dmitry Trunikov

    ConnectionFactory && HA-JNDI

    Dmitry Trunikov Newbie

      Hi ALL!

      Environment:
      AS: jboss-4.2.2.GA
      Command line: run.bat -c all -b 0.0.0.0 -g XXX
      Problem:
      My application has servlet which has init code to obtain queue and JMS connection factory. The code can obtain a reference to queue but it fails to get reference on a connection factory:

      11:20:00,925 ERROR [[/phs]] Servlet /xxx threw load() exception
      javax.naming.NameNotFoundException: jms/ConnectionFactory
       at org.jboss.ha.jndi.TreeHead.lookup(TreeHead.java:242)
       at org.jboss.ha.jndi.HAJNDI.lookup(HAJNDI.java:155)
       ...
      

      The init code is:
      Properties p = new Properties();
       p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
       p.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
       p.put(Context.PROVIDER_URL, "localhost:1100"); // HA-JNDI port.
       InitialContext ctx = new InitialContext(p);
       queue = (Queue) ctx.lookup("queue/xxxQueue");
       QueueConnectionFactory qcf = (QueueConnectionFactory) ctx.lookup("jms/ConnectionFactory" /*"jnp://localhost:1100/ConnectionFactory"*/);
      

      The error occures on the last line in the code above. I can avoid the error by using commented out JNDI name. But I think that JNDI name "jms/ConnectionFactory" should be valid too because I have mappings in web.xml and jboss-web.xml descriptors. In any case it is not clear why the first lookup passed and the second one fails. Please point me what I missed. Thanks in advance for any reply.

      web.xml:
      <resource-ref>
       <description>Default QueueFactory</description>
       <res-ref-name>jms/ConnectionFactory</res-ref-name>
       <res-type>javax.jms.QueueConnectionFactory</res-type>
       <res-auth>Container</res-auth>
       </resource-ref>
      
       <resource-ref>
       <description>Queue</description>
       <res-ref-name>queue/xxxQueue</res-ref-name>
       <res-type>javax.jms.Queue</res-type>
       <res-auth>Container</res-auth>
       </resource-ref>
      


      jboss-web.xml:
       <resource-ref>
       <res-ref-name>jms/ConnectionFactory</res-ref-name>
       <jndi-name>jnp://localhost:1100/ConnectionFactory</jndi-name>
       <res-type>javax.jms.QueueConnectionFactory</res-type>
       </resource-ref>
      
       <resource-ref>
       <res-ref-name>queue/phsMessagesGatewayQueue</res-ref-name>
       <jndi-name>jnp://localhost:1100/queue/xxxQueue</jndi-name>
       <res-type>javax.jms.Queue</res-type>
       </resource-ref>
      



        • 1. Re: ConnectionFactory && HA-JNDI
          Dmitry Trunikov Newbie

          BTW, JNDI view for my application is as follow:

          java:comp namespace of the zzz.ear/zzz.war application:
          
           +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
           +- ORB (class: org.jacorb.orb.ORB)
           +- env (class: org.jnp.interfaces.NamingContext)
           | +- queue (class: org.jnp.interfaces.NamingContext)
           | | +- aaaQueue[link -> jnp://localhost:1100/queue/aaaQueue] (class: javax.naming.LinkRef)
           | +- security (class: org.jnp.interfaces.NamingContext)
           | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
           | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
           | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
           | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)
           | +- jms (class: org.jnp.interfaces.NamingContext)
           | | +- ConnectionFactory[link -> java:/JmsXA] (class: javax.naming.LinkRef
          


          • 2. Re: ConnectionFactory && HA-JNDI
            Dmitry Trunikov Newbie

             

            java:comp namespace of the zzz.ear/zzz.war application:

            +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
            +- ORB (class: org.jacorb.orb.ORB)
            +- env (class: org.jnp.interfaces.NamingContext)
            | +- queue (class: org.jnp.interfaces.NamingContext)
            | | +- aaaQueue[link -> jnp://localhost:1100/queue/aaaQueue] (class: javax.naming.LinkRef)
            | +- security (class: org.jnp.interfaces.NamingContext)
            | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
            | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
            | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
            | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)
            | +- jms (class: org.jnp.interfaces.NamingContext)
            | | +- ConnectionFactory[link -> java:/JmsXA] (class: javax.naming.LinkRef


            I apologize for mistake in previous post. Patched version is as follow:

            java:comp namespace of the zzz.ear/zzz.war application:
            
             +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
             +- ORB (class: org.jacorb.orb.ORB)
             +- env (class: org.jnp.interfaces.NamingContext)
             | +- queue (class: org.jnp.interfaces.NamingContext)
             | | +- aaaQueue[link -> jnp://localhost:1100/queue/aaaQueue] (class: javax.naming.LinkRef)
             | +- security (class: org.jnp.interfaces.NamingContext)
             | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
             | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | +- jms (class: org.jnp.interfaces.NamingContext)
             | | +- ConnectionFactory[link -> jnp://localhost:1100/ConnectionFactory] (class: javax.naming.LinkRef)