4 Replies Latest reply on Nov 7, 2005 11:36 AM by Claire Costello

    JMS, JNDI and remote client access.

    Claire Costello Newbie

      Hi All,

      I'm using JBoss 4.0.2 and integrated ActiveMQ to deploy an MDB. Things seem to deploy just fine as there is a Global JNDI entry for the queue. (JMX Console). However, when I try to connect remotely, I can create the context, but am having problems connecting to the resource. See code below:

      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, "jnp://hostname:1099");
      InitialContext ctx = new InitialContext(p);
      Object tmp = ctx.lookup("queue");
      System.out.println("Class: " + tmp.getClass().getCanonicalName().toString());

      Why is the returned object of type: org.jnp.interfaces.NamingContext?

      In the Global JNDI namespace of the JMX Console JNDI view, there is the following entry:

      +- queue (class: org.jnp.interfaces.NamingContext)
      | +- MyQueue (class: org.activemq.message.ActiveMQQueue)

      I can't seem to get a connection factory to send messsages to the queue. I hope it's something obvious. Can anyone tell me where I'm going wrong here? I want a handle to the "MyQueue" queue.

      Many thanks,

        • 1. Re: JMS, JNDI and remote client access.
          jaikiran pai Master


          "clairecostello" wrote:

          I want a handle to "MyQueue" queue

          In your code, instead of :

          Object tmp = ctx.lookup("queue");

          do the following:

          Object tmp = ctx.lookup("queue/MyQueue");

          • 2. Re: JMS, JNDI and remote client access.
            Claire Costello Newbie

            Thanks for your reply. I tried what you suggested but get the following error output:

            Exception in thread "main" java.lang.ExceptionInInitializerError
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(Unknown Source)
            at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
            at javax.naming.spi.NamingManager.getObjectFactoryFromReference(Unknown Source)
            at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
            at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1110)
            at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1127)
            at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:690)
            at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
            at javax.naming.InitialContext.lookup(Unknown Source)
            at com.iwise.process.test.EventQueueClient.sendToEventQueue(EventQueueClient.java:56)
            at com.iwise.process.test.EventQueueClient.main(EventQueueClient.java:30)
            Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException
            at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:558)
            at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:355)
            at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:390)
            at org.activemq.jndi.JNDIReferenceFactory.<clinit>(JNDIReferenceFactory.java:40)
            ... 12 more
            Caused by: java.lang.NullPointerException
            at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:543)
            ... 15 more

            Any clues here? It's like it doesn't know about "MyQueue" or something but yet it is listed in the JNDI service of JMX Console.

            • 3. Re: JMS, JNDI and remote client access.
              colincrist Newbie

              I suspect that when you view destinations bound via JNDI in the admin console, JBoss is not trying to defreference then, rather it just lists whats there with their classname - aka javax.naming.Context.listBindings and the way in which JNDI binds objects via a Reference.

              Your problem is config/classpath related I would guess.

              This looks smelly:

              Caused by: java.lang.NullPointerException
              at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:543)
              ... 15 more

              Consequently, I'd suggest you post on the ActiveMQ newsgroups for some feedback from users there as its more likely it's your configuration with ActiveMQ that is causing you woes.

              You can browse them online:




              • 4. Re: JMS, JNDI and remote client access.
                Claire Costello Newbie

                Hi Colin,

                Thanks for your reply. I'll have a look through activemq forum.