6 Replies Latest reply on Feb 20, 2012 7:53 AM by aslamcl

    JNDI Lookup Issue java:/queue/test

    aslamcl

      On server startup I get following message in console.

       

      15:01:55,312 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service

      thread 1-1) trying to deploy queue jms.queue.testQueue

      15:01:55,328 INFO  [org.jboss.as.messaging] (MSC service thread 1-1) JBAS011601:

      Bound messaging object to jndi name java:/queue/test

       

      I have tried to lookup "java:/queue/test" using following jndi code. But I get exception.

       

      Properties props = new Properties();

      props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      props.setProperty(Context.PROVIDER_URL, "jnp://localhost:1099");
      props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
      InitialContext ctx = new InitialContext()

      ;

       

      ctx.lookup("java:/queue/test");

       

      javax.naming.NameNotFoundException: jboss/datasources/ExampleDS

          at org.jboss.ha.jndi.HAJNDI.lookupRemotely(HAJNDI.java:265)

          at org.jboss.ha.jndi.HAJNDI.lookup(HAJNDI.java:206)

          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:597)

          at org.jboss.ha.framework.server.HARMIServerImpl.invoke(HARMIServerImpl.java:209)

          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:597)

          at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305)

          at sun.rmi.transport.Transport$1.run(Transport.java:159)

          at java.security.AccessController.doPrivileged(Native Method)

          at sun.rmi.transport.Transport.serviceCall(Transport.java:155)

          at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)

          at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)

          at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)

          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

          at java.lang.Thread.run(Thread.java:662)

          at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)

          at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)

          at sun.rmi.server.UnicastRef.invoke(Unknown Source)

          at org.jboss.ha.framework.server.HARMIServerImpl_Stub.invoke(Unknown Source)

          at org.jboss.ha.framework.interfaces.HARMIClient.invokeRemote(HARMIClient.java:225)

          at org.jboss.ha.framework.interfaces.HARMIClient.invoke(HARMIClient.java:327)

          at $Proxy0.lookup(Unknown Source)

          at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:726)

          at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)

          at javax.naming.InitialContext.lookup(Unknown Source)

          at com.pcs.obix.Main.getConnectionFactory(Main.java:27)

          at com.pcs.obix.Main.main(Main.java:14)

       

      Note: I tried to look up other things aswell, but for everything I get the above error message. Please help;

        • 1. Re: JNDI Lookup Issue java:/queue/test
          aslamcl

          I forogot to add the sever details. This happens in jboss-as-7.1.0.Beta1b.

          • 2. Re: JNDI Lookup Issue java:/queue/test
            badr

            Have you already created a resource with this JNDI name : "java:/queue/test"

             

            I guess not :S

            • 3. Re: JNDI Lookup Issue java:/queue/test
              lafr

              AFAIK Context.INITIAL_CONTEXT_FACTORY or java.naming.factory.initial should be org.jboss.as.naming.InitialContextFactory now.

              • 4. Re: JNDI Lookup Issue java:/queue/test
                aslamcl

                I haven't created any jndi. But by defaul java:/queue/test is created. That is why I get following log when I start the server.

                 

                ice$ResourceAdapterActivator] (MSC service thread 1-3) IJ020002: Deployed: file:

                //RaActivatorhornetq-ra

                15:01:55,250 INFO  [org.jboss.as.deployment.connector] (MSC service thread 1-3)

                JBAS010401: Bound JCA ConnectionFactory [java:/JmsXA]

                15:01:55,281 INFO  [org.jboss.as.messaging] (MSC service thread 1-7) JBAS011601:

                Bound messaging object to jndi name java:/topic/test

                15:01:55,297 INFO  [org.jboss.as.messaging] (MSC service thread 1-8) JBAS011601:

                Bound messaging object to jndi name java:/ConnectionFactory

                15:01:55,297 INFO  [org.jboss.as.messaging] (MSC service thread 1-5) JBAS011601:

                Bound messaging object to jndi name java:/RemoteConnectionFactory

                15:01:55,312 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service

                thread 1-1) trying to deploy queue jms.queue.testQueue

                15:01:55,328 INFO  [org.jboss.as.messaging] (MSC service thread 1-1) JBAS011601:

                Bound messaging object to jndi name java:/queue/test

                15:01:55,328 INFO  [org.jboss.as.jacorb] (MSC service thread 1-4) CORBA Naming S

                ervice Started

                 

                 

                Noted : As Frank suggested I have tried with org.jboss.as.naming.InitialContextFactory alsom. But again same exception.

                javax.naming.NameNotFoundException: queue/test

                    at org.jboss.ha.jndi.HAJNDI.lookupRemotely(HAJNDI.java:265)

                    at org.jboss.ha.jndi.HAJNDI.lookup(HAJNDI.java:206)

                    at sun.reflect.GeneratedMethodAccessor4852.invoke(Unknown Source)

                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                    at java.lang.reflect.Method.invoke(Method.java:597)

                 

                ======================code===================

                 

                Properties props = new Properties();

                props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.as.naming.InitialContextFactory");

                props.setProperty(Context.PROVIDER_URL, "jnp://localhost:1099");

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

                           

                InitialContext ctx = new InitialContext();

                 

                ctx.lookup("java:/queue/test");

                ==============================================

                 

                What shall I do? Please help.

                • 5. Re: JNDI Lookup Issue java:/queue/test
                  prasad.deshpande

                  ======================code===================

                   

                  Properties props = new Properties();

                  props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.as.naming.InitialContextFactory");

                  props.setProperty(Context.PROVIDER_URL, "jnp://localhost:1099");

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

                             

                  InitialContext ctx = new InitialContext();

                   

                  ctx.lookup("java:/queue/test");

                  ==============================================

                   

                  What shall I do? Please help.

                   

                  Are you looking-up from standalone remote client? if so, you need to pass following properties to initialcontext

                   

                  java.naming.factory.url.pkgs=org.jboss.ejb.client.naming

                  java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory

                  java.naming.provider.url=remote://localhost:4447

                  jboss.naming.client.ejb.context=true

                   

                  Also, you'll need your test queue to be bound to java:jboss/exported/queue/test" (in standalone.xml) & you can simply lookup using ctx.lookup("queue/test"); -- to access over remote clients it's necessary to bind it to java:jboss/exported/

                   

                  However, if you are looking-up in server side then you don't need to pass any properties to initialcontext simply create an initial context with default constructor & use ctx.lookup("java:jboss/exported/queue/test"); (assuming it's bound to java:jboss/exported/queue/test) that should do.

                   

                   

                  Also, 7.1 Final is release so you can now download that one rather than using beta version.

                  1 of 1 people found this helpful
                  • 6. Re: JNDI Lookup Issue java:/queue/test
                    aslamcl

                    Prasad, thanks for your reply. I have tried with 'Thunder'.

                    Following code works fine.

                    final Properties env = new Properties();

                                env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

                                env.put(Context.PROVIDER_URL, "remote://localhost:4447");

                                Context context = new InitialContext(env);

                                Queue queue = (Queue) context.lookup("jms/queue/test");