Problem solve Get help with specific problems with your technologies, process and projects.

How can I access an EJB in WebSphere on one machine from a Java program on another?

How can I access an EJB which exists in WebSphere (WAS Server) on one machine from a Java program on another machine in the same network?

You are describing the exact problem EJB was originally intended to solve. Up to and including EJB 2.x, with an EJB successfully deployed to the WAS, you simply perform a JNDI lookup of the EJB from a remote client and then make calls to the EJB as if it were running in the same VM. This requires you to know the EJB vendor's lookup URL, the JNDI name of the EJB, security credentials, etc. With EJB 3.0, all of the look-up information and functionality will be separated from the client code.

The following demonstrates a typical scenario for finding an EJB and calling a method on it:  

java.util.Properties env = new java.util.Properties();





   java.security.Identity id = getIdentity();

   env.put(Context.SECURITY_PRINCIPAL, id);

   javax.naming.Context initial = new javax.naming.InitialContext(env);

   Object objref =


   MyEJBHome home =



   MyEJB myEJB = home.create();


Dig Deeper on Topics Archive