Accessing an EJB from a Java Application using an embeddable container

The embeddable EJB container allows EJBs to be executed outside of a Java EE environment. Standalone Java SE applications can use the embeddable container to execute EJBs. In addition, it can be used for unit testing of EJBs.

The embeddable container does not require the installation of a server. As a result it has a smaller footprint and will start faster. However, MDBs and inbound RMI over IIOP (RMI/IIOP) (Remote Method Invocation (RMI) (Internet Inter-Orb Protocol (IIOP)) calls are not supported. Efficiency features found in the Java EE environment, like clustering, are not available.

How to do it...

Create a standard Java SE application with the following main method.

public ...

Get EJB 3.1 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.