1 2 Previous Next 21 Replies Latest reply on Apr 8, 2008 3:52 AM by resh123 Go to original post
      • 15. Re: Basic EJB  - cant be invoked from client

        You're right. That would show up later.

        And of course he should change his code to use the remote interface rather than the local one unless it's running inside the ear.

        • 16. Re: Basic EJB  - cant be invoked from client
          jaikiran

           

          "jeff.rosen" wrote:

          The problem is that he hasn't told the client where the naming provider is located. One possible solution would be to modify the something like:

          InitialContext ic = new InitialContext();
          Context jndiRoot = (Context) ic.lookup("jnp://localhost:1099");
          CalculatorLocal calculator = (CalculatorLocal)jndiRoot.lookup("CalculatorBean/local");
          


          Assuming that JBoss is running on the same machine as the client, otherwise adjust the URL accordingly.


          That actually is a good thing to try. All this while, i have been assuming that since localhost:1099 is the default URL that will be used by JBoss, he need not specify it as part of the InitialContext or jndi.properties. Probably pass all the JNDI related properties to the InitialContext constructor and see if that works:
           Properties props = new Properties();
           props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
           props.put(Context.PROVIDER_URL,"jnp://localhost:1099");
           props.put(Context.URL_PKG_PREFIXES,"org.jboss.naming.jnp.interfaces");
           Context ctx = new InitialContext(props);
           ctx.lookup(.....);


          • 17. Re: Basic EJB  - cant be invoked from client

            the client doesn't know you want to talk to JBoss...
            And it will never need to know, all it needs to know is that it has a jar file with client libraries and some properties telling it where to get an InitialContext.

            Plug in OAS jars and properties and you're talking to Oracle, plug in BEA jars and properties and you're talking to WebLogic.

            • 18. Re: Basic EJB  - cant be invoked from client
              resh123

              Hi All,

              Thanks very much for the replies. As suggested by "jeff.rosen" I tried the following:



               InitialContext ic = new InitialContext();
               Context jndiRoot = (Context) ic.lookup("jnp://localhost:1099");
               CalculatorRemote calculator = (CalculatorRemote)jndiRoot.lookup("CalculatorBean/Remote");
              
              


              i.e. I specified the jndiRoot and changed Local to Remote. However, now i get the following exception:

              Exception in thread "main" javax.naming.NameNotFoundException: Remote 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 org.jnp.server.NamingServer.lookup(NamingServer.java:270)
               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:585)
               at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
               at sun.rmi.transport.Transport$1.run(Transport.java:153)
               at java.security.AccessController.doPrivileged(Native Method)
               at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
               at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
               at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
               at java.lang.Thread.run(Thread.java:595)
               at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
               at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
               at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
               at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
               at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
               at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
               at javax.naming.InitialContext.lookup(InitialContext.java:351)
               at uk.co.autotrader.ejb3.client.CalculatorClient.main(CalculatorClient.java:26)
              
              




              • 19. Re: Basic EJB  - cant be invoked from client
                jaikiran

                 

                javax.naming.NameNotFoundException: Remote not bound


                This means that you are using an incorrect jndi-name while doing the lookup. Use the JNDIView from the jmx-console http://wiki.jboss.org/wiki/en/DisplayTheJNDITreeWithTheJMXConsole to see the exact name jndi-name to which your bean is bound. Then use that jndi-name in the client lookup.

                • 20. Re: Basic EJB  - cant be invoked from client

                  remember that jndi lookups are case sensitive. It's "remote", not "Remote" for example.

                  • 21. Re: Basic EJB  - cant be invoked from client
                    resh123

                    on changing "Remote" to "remote" it worked!!
                    Finally!! Thanks to all of you!

                    1 2 Previous Next