Java, Software Development

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

java Sort Enum Properties Monitor Directory File Lambda Expression parameter return types Validate XML String XSD ExecutorService AutoCloseable Try-With-Resources Convert LocalDateTime OffsetDateTime Run Codes Before Shutdown XML Tag Lambda PostgreSQL JDBC invoke JavaScript Applet SFTP Batch hang block main thread MySQL JDBC try-with-resources delete Unencrypted SoapFault Apache CXF Remove XML Element XSLT skip execute finally public static void main constructor fields Eclipse convert Iterator Stream StreamSupport XMLEncoder XMLDecoder rename P6Spy JDBC Example PDF Version JasperReports Run from Ant iReport Page Numbers Count entities persistence context hibernate

This is the second part of the blog I wrote about EJB2.0 with OpenEJB. In the first part, we created a stateless session bean and deployed it in OpenEJB. In 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 interfaces as 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.


Got comments, or suggestions? Please visit our Facebook page!

You Might Also Like