Invoking an EJB deployed in WAS using Java Client

EJB’s popularly known as Enterprise Java Beans are one of the state-of-the-art feature of J2EE. EJB’s are mainly used for handling transactions, security, providing remote services etc. Even though lot of Object Relational Mapping Frameworks like Hibernate has replaced EJB’s which is considered to be so heavy in any Enterprise Application. Invoking an EJB inside the Application Server Container is quite simple and process is not as tedious when you try to do the same from outside the Application Server. Today I am going to explain how to invoke an EJB service which is deployed in a remote machine using a plain java client.

Who are qualified to be the clients?

EJB clients are those applications, components, systems, and services that try to access the EJB to fulfill a request or get a service. The client can be a device client , applet client , stand-alone java clients, EJB clients, CORBA clients, Legacy clients, JMS clients, windows clients and clients from other plat forms. Here I am gonna talk about only stand-alone java clients…

How java stand- alone client works?

Any java application can call an EJB service that is running on a remote application server using RMI calls. Since EJB’s internally uses RMI over IIOP.

How to access the EJB?

To look up an EJB that is remotely deployed, the stand-alone java clients has to make a look-up call through JNDI service running at a part icular port . JNDI is nothing but a naming-service which holds all the “object to name bindings” that exists in the server . Once they get the proper handle they can start to invoke the methods from the remote reference obtained using those handle. I am not here to explain the basics; just I have given an overview that ’s all.

How to create an EJB-Client.jar?

This is just to tell you how to create ejb-client .jar. What needs to be there?

1. EJB Remote Interface
2. EJB Home
3. Generated stubs
4. Necessary class files that can be used to invoke the remote methods.
5. Needed jars.

Make the client JAR available to the remote client . For Web applications, put the ejbclient.jar in the / lib directory. For non-Web clients, include ejb-client .jar in the client’s classpath. All the above said information is as per EJB-specification and from now onwards I am gonna proceed with Websphere specific information.

Points to be noted for Websphere:

1 . Websphere JNDI Standalone client will only work with the IBM JRE.
2 . And IBM does not ship their JRE standalone. (at least their 1.4 JRE)

Note: You will not face the above said problem in JBOSS and Weblogic. You just have to include the necessary jar that ’s all.

Why things are troubling us?

That was related to differences in the information used in the IBM orb and others. Sun changed the spec to ensure such issues went away. All complying implementations should interoperate out of the box now.

Process for Accessing the EJB services from Websphere:

This document provides the guidelines for accessing the Ejb services running in the Websphere Application server from any other external application servers or applications.

JAR Collection

To access the Ejb service some of the jar files have to include to the classpath of the application. This has to be collected from the Websphere lib directory. They are,

1 . bootstrap.jar
2 . ecutils.jar
3 . ffdc.jar
4 . idl.jar
5 . iwsorb.jar
6 . j2ee.jar
7 . lmproxy.jar
8 . naming.jar
9 . namingclient .jar
10 . ras.jar
11 . sas.jar
12 . utils.jar

JRE Collection

The compilation conflict occurs from the versions of the JRE used. As we access the IBM specific classes we need to have IBM jre collection. Create jre library from the java folder in the Websphere. And also it is must to use sun jre along with
that , and then include the j2ee.jar from sun provided J2SDKEE ( this holds the except ions of Ejb) .

1. IBM jre ( this library has to be created from the whole java directory)

2. SUN jre ( this library has to be created from jdk not jre)

3. j2ee.jar ( j2sdkee)


IBM maintains a property file for establishing connect ions with the iiop. So the application should include that property file. It is named as


Context Parameters

PROVIDER_URL = iiop: //hostname:2809


Post a Comment

Popular Posts