Java, Software Development

EJB3.0 Stateless Session Beans with Glassfish 3.1.1 (Open Source Edition)

EJB is not tricky. Well, not as much if you do not have a good grasp of Servlet/JSP architecture and a great deal of Java web technologies experience.  Almost the same stuff can be seen in the EJB world – container, container-managed objects, life-cycles, container callback methods, deploy-time descriptors, etc.

So, if you are pretty familiar with the basics, EJB is easier than you think. EJB2.x or EJB3.x? It does not matter.

Software applications used

  • Glassfish 3.1.1 – Open Source Edition
  • JDK1.6 update 21
  • Eclipse Ganymede
  • Windows XP

First, download a Glassfish installer from, run it, and use default settings during installation. Then, create a Java project in Eclipse and reference the javax.ejb.jar (<GLASSFISH_HOME>/glassfish/module) library.


Eclipse Project

The client

The Remote Interface

The Local Interface

The Stateless Session bean

Then, build the codes in Eclipse and jar them up – including the client. This will make the testing the client easier, but we need to specify the Main-Class during the creation of the jar file. Jar command:


Jar file

The Manifest.txt contains the following (plus a carriage return):

Finally, deploy the jar via the GlassFish Server Administration Console.


Deployed EJB3.0 Session Bean

Now, let us test the client. Copy the jar file to the directory shown in the image just below and use appclient.bat.


Test EJB client using appclient.bat

You Might Also Like