Software Development

EJB2.0 with OpenEJB: Session Bean and the Remote Client

This is the second part of the blog I wrote about EJB2.0 with OpenEJB. On the first part, we created a stateless session bean and deployed it in OpenEJB. On this part, we write, and test a simple Java class that remotely uses the deployed session bean.

The link to the first part: EJB2.0 with OpenEJB: Stateless Session Bean in Action

One of the cardinal rules in writing EJB2.0 clients is to always include the interface types in the client project. The image below shows the EJB bean and client projects. Notice that the client project also has the same two interfaces found in the EJB project (ejb2test). To successfully build and run the client application, the two jar files are needed to be in the classpath:

  1. javaee-api-5.0-3.jar
  2. openejb-client-3.1.4.jar.


EJB2.0 bean and client projects

The client class:

Notice a JNDI name “AdviceBeanRemoteHome” is used instead of “AdviceBean”. This is an OpenEJB EJB-JNDI naming convention. The EJB server appended “RemoteHome” to our original EJB name during start-up.

After building the client project, copy the classes and jar files to a remote machine (or virtual machine).


Client app in Ubuntu

Then, open a terminal from which the execute the client application.


You Might Also Like