3 Replies Latest reply on Oct 25, 2002 7:38 AM by adrian.brock

    JNDI Confusion

    stevefrare

      Hi:

      In my start to learn J2EE / JBoss I am working with JNDI since it is used a lot. I have take the first example from the book "JNDI API Tutorial and Reference" and was successfully able to lookup a JMS queue via:

      String name = "queua/A";
      // Create the inital context
      Context ctx = new InitialContext(env);

      // Look up an object
      Object obj = ctx.lookup(name);

      // Print it
      System.out.println(name + " is bound to: " + obj);

      However if I change name to something other than a queue my lookup fails with a "Problem looking up java:/JmsXA: javax.naming.NameNotFoundException: JmsXA not bound" where in this case I am replacing name with 'java:/JmsXA'.

      I can see that it is bound via the startup output:

      09:21:42,637 INFO [JmsXA] Bound connection factory for resource adapter 'JMS Adapter' to JNDI name
      'java:/JmsXA'

      Could somebody point me in the right direction?

      Thanks
      Steve

        • 1. Re: JNDI Confusion

          java:/ is the local namespace.
          It can only be used within same JVM.

          JmsXA is pooled, there would be little point pooling
          if you then transfered stuff over the wire.

          It also relies on an the App Server to control it,
          read the JMS spec section 8 if you are interested.

          Since JBoss is modular, you can probably create a
          mini-jboss for your client with a local JmsXA
          session pool.

          Regards,
          Adrian

          • 2. Re: JNDI Confusion
            stevefrare

            Hi Adrian:

            Thank you. I am a bit confused since the J2EE samples from Sun client programs start out like:

            (From ConverterClient.java examples for the reference implementation)
            Context myEnv = (Context)ctx.lookup("java:comp/env");
            Object obj = myEnv.lookup("Counter");

            Not that I have ever got those to work, the following does work however:

            Object obj = ctx.lookup("Counter");

            So I suppose the example is wrong?

            Also the use of me calling JmsXA was just to see if I could look it up using JNDI, not to do anything with it.

            Thanks
            Steve

            • 3. Re: JNDI Confusion

              The examples are for an "application client".

              It's an under speced and optional part of j2ee.

              Basically, it allows you to run a normal java class
              with a java:comp namespace configured from a deployment
              descriptor and all the j2ee classes in your classpath.

              JBoss doesn't have an implementation.

              Regards,
              Adrian