4 Replies Latest reply on Nov 20, 2007 6:59 AM by jaikiran

    InitialContext lookup gives me a

      Am trying to access a remote EJB from a stand alone java client, but are getting an exception. This is the exception:

      javax.naming.NameNotFoundException: aslan.dk.JEJBWebCam.server.beans.RecordingRemote not bound
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
      at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
      at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
      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:885)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
      at java.lang.Thread.run(Thread.java:619)
      at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
      at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142)
      at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
      at javax.naming.InitialContext.lookup(InitialContext.java:392)
      at aslan.dk.jejbwebcam.Main.(Main.java:36)
      at aslan.dk.jejbwebcam.Main.main(Main.java:48)



      My code looks like this:


      @Stateless
      public class RecordingBean implements RecordingRemote{
      
       /** Creates a new instance of RecordingBean */
       public RecordingBean() {
       }
       public String hello() {
       return "Hello Batman";
       }
      }
      //-----------------------------------------------
      @Remote
      public interface RecordingRemote {
       public String hello();
      
      }
      //-----------------------------------------
      
      
       public Main() {
       InitialContext ic;
       try {
      
       Hashtable ht = new Hashtable();
       ht.put(InitialContext.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
       ht.put(InitialContext.PROVIDER_URL,"jnp://localhost:1099");
       ht.put(InitialContext.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
      
       ic = new InitialContext(ht);
      
       RecordingRemote bean = (RecordingRemote) ic.lookup(RecordingRemote.class.getName());
      
       System.out.println(bean.hello());
       } catch (Exception ex) {
       ex.printStackTrace();
       }
       }
      
      



      Am using jboss-4.2.0.GA and java 1.5. Can anyone help me with this, I have been strugling with it for several days now, without any luck?



        • 1. Re: InitialContext lookup gives me a
          jaikiran

           

          RecordingRemote bean = (RecordingRemote) ic.lookup(RecordingRemote.class.getName());


          By default, the bean will be bound to "EAR-FILE-BASE-NAME/BEANCLASSNAME/remote". So if you EAR file name is myApp.ear and then the lookup will be:

          RecordingRemote bean = (RecordingRemote) ic.lookup("myApp/RecordingBean/remote");
          

          Alternately, you can check the JNDI name of your bean by following the steps below:

          - Go to http://localhost:8080/jmx-console
          - Search for service=JNDIView
          - Click on that link
          - On the page that comes up click on the Invoke button beside the list() method
          - The page that comes up will show the contents of the JNDI tree. Post that here.



          • 2. Re: InitialContext lookup gives me a

            Thx jaikiran

            U saved my day :-)

            • 3. Re: InitialContext lookup gives me a
              kavipriyag

              I am also getting the same exception as

              Javax.naming.NamenotFoundException:TransactionManager not bound Exception.

              Can you please help me out in this issue.

              • 4. Re: InitialContext lookup gives me a
                jaikiran

                kavipriyag,

                You should have created a new topic for this issue.

                Furthermore, you have to provide more details about your application and more details as to when this exception occurs. Also, the entire exception stacktrace will help in pointing you in the right direction.