1 Reply Latest reply on Mar 16, 2012 9:29 AM by gimbal2

    lookup remote session bean from other machine


      I am trying to invoke a remote interface but i always have "EntAppEJB" Name Not Found exception.
      I am using glassfish 3.1.2; netbeans 7.1

      The session bean is more less like this:
      public class MySession implements MySessionRemote {
          public String getResult() {
              return "Hello world";
          // Add business logic below. (Right-click in editor and choose
          // "Insert Code > Add Business Method")
      The client code is as below:
                 Properties props = new Properties();
                 props.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
                 props.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
                 props.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
                 props.setProperty("org.omg.CORBA.ORBInitialHost", "");
                 props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
                 Context ic = new InitialContext(props);
                 Object obj = ic.lookup("java:global/EntAppEJB/MySessionRemote"); // EntAppEJB is project name
                 MySessionRemote ans = (MySessionRemote) PortableRemoteObject.narrow(obj, MySessionRemote.class);
                 System.err.println("result = " + ans.getResult());
             catch(NamingException ne){
      Do you have any ideas?

      thank you for your help!

      -Hoang Long

      Edited by: CardM on Mar 16, 2012 2:08 AM
        • 1. Re: lookup remote session bean from other machine
          The JNDI name is already not correct according to the EJB 3.1 specs, but perhaps under Glassfish this one works. I would have expected something like this:
          Assuming the EJB is not deployed as part of an EAR. And of course replace package with the proper package name.

          In any case, this:
          // EntAppEJB is project name
          can be inprecise. It is not the name of the project that matters, it is the name of the EJB module. Whatever the case, you are not being lied to. You are using the wrong name, so figure out what you should be using.