In order for a client to connect to your remote GlassFish server you need to add a second IIOP listener with the hostname listening at a different port (ex: 3701). You can do this via the GlassFish admin console.
Create a Java project in Eclipse that will be a standalone ejb 3.0 client application.
When deploying the previously created EJB jar on glassfish using the admin console check the option that creates the client .jar file. Then locate the *Client.jar file on the server and make your project depend on this jar.
Your client app should have code similar to below:
public class Client {
@SuppressWarnings("unchecked")
public void runTest() throws Exception {
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("org.omg.CORBA.ORBInitialHost", "");
// NOTE: IIOP is set on port 3701 but this works on port 3700
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
InitialContext ctx = new InitialContext(props);
OrderBean bean = (OrderBean) ctx.lookup("ejb/OrderBean");
Order result = bean.findByOrderNum(9);
System.out.println(result.getDescript());
}
public static void main(String[] args) {
Client cli = new Client();
try {
cli.runTest();
} catch (Exception e) {
e.printStackTrace();
}
}
}