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();
}
}
}