This discussion is archived
1 Reply Latest reply: Mar 16, 2012 2:29 AM by gimbal2 RSS

lookup remote session bean from other machine

859967 Newbie
Currently Being Moderated
Hi,

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:
@Stateless
public class MySession implements MySessionRemote {

    @Override
    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:
  try{
           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", "192.168.15.222");
           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){
           ne.printStackTrace();
       }
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
    gimbal2 Guru
    Currently Being Moderated
    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:
    java:global/EntAppEJB/MySession!package.MySessionRemote
    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.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points