2 Replies Latest reply on Feb 3, 2005 12:35 PM by bperry

    access Queue with JNDI from outside the app server

    bperry

      Hello,

      I am accessing a JMS Queue that is bound to the Global JNDI namespace under "jms/epdqueue." I don't have a problem getting the Queue object from components running within JBoss. My code has to be able to access the queue from outside the JVM/app server. I get the InitialContext okay but the lookup returns a javax.naming.Reference object instead of the Queue.What are the steps to get the actual Queue object from the Reference? Here's how the test code sets everything up:

      Properties props = System.getProperties();
      props.put("java.naming.factory.initial",
      "org.jnp.interfaces.NamingContextFactory");

      props.put("java.naming.provider.url", "jnp://localhost:1099");

      props.put("java.naming.factory.url.pkgs",
      "org.jboss.naming:org.jnp.interfaces");

      System.setProperties(props);

      try {

      namingCtx = new InitialContext();

      Object tmp = namingCtx.lookup("jms/epdqueue");

      if (tmp instanceof javax.naming.Reference) {
      Reference ref = (Reference) tmp;
      System.out.println(ref.getClassName());
      System.out.println(ref.getFactoryClassName());
      }
      //etc...

      How can I return the javax.jms.Queue from the lookup instead?

      Thanks,

      Bruce

        • 1. Re: access Queue with JNDI from outside the app server
          narayanrm

           

          
          java.util.Hashtable env = new java.util.Hashtable();
           env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
           env.put(javax.naming.Context.PROVIDER_URL,"jnp://localhost:1099");
           env.put(javax.naming.Context.URL_PKG_PREFIXES,"org.jnp.interfaces");
           Context context = new InitialContext(env);
          
          javax.jms.QueueConnectionFactory ref = (javax.jms.QueueConnectionFactory) context.lookup("ConnectionFactory");
          
          javax.jms.QueueConnection conn = ref.createQueueConnection();
           javax.jms.Queue que = (javax.jms.Queue) context.lookup("queue/A");
          
          


          • 2. Re: access Queue with JNDI from outside the app server
            bperry

            Okay, so the problem was the absence of the jbossall-client.jar during compilation. I included that in the project and now can a Queue object. Thanks for you help.

            Bruce