IIOP standalone EJB3 client lookup to Glassfish 3.1.2

Setup to run a standalone EJB client and lookup to a Glassfish running EJB 3.1 stateless ejb.

  • Install Glassfish plugin in Eclipse.
  • Create a Enterprise Aplication Project using Glassfish server as the target runtime.
  • Create a HelloWorld example:
public interface HelloWorld {}

public class HelloWorldEjb implements HelloWorld {}
  • Create a Application Client Project using Glassfish server as the target runtime.
  • Add gf-client.jar to the project classpath. gf-client.jar is included on the glassfish plugin folder inside eclipse, or in the glassfish standalone installation.
  • Create the plain java code as the following:
InitialContext ctx;
HelloWorld ejbRef = null;
try {
   ctx = new InitialContext();

   ejbRef = (HelloWorld) ctx.lookup("eu.pedrocardoso.HelloWorld");


} catch (NamingException e) {


  • Optionally we can give properties to the initial context:
Properties p = new Properties();

Default Glassfish iiop port is 3700

Tags: ,

Leave a Reply