Developing EJB applications on Liberty

An Enterprise Beans application (EJB) is a set of beans that are packaged as a combination of a Java™ archive file (JAR), web application archive file (WAR), or an enterprise application archive file (EAR). Liberty provides several features to enable support for Enterprise Bean applications. 

About this task

The WebSphere® Application Server Liberty provides full support for the Enterprise Beans specification. The Enterprise Beans specification also defines a lite subset, which is also a configurable feature that is provided in Liberty. In addition, several other optional features that enable server configurations that only support subsets of the full Enterprise Beans specification are available. These subsets enable the use of server configurations that use fewer resources when all capabilities of the Enterprise Beans specification are not used by the installed applications.

For information about developing Enterprise Beans applications by using WebSphere Developer Tools, see Developing EJB 3,x applications.

Attention:

Beginning with Jakarta EE 9, the Enterprise Beans feature names that previously started with ejb are renamed to start with enterpriseBeans. For example, as of the Jakarta EE 9.1 release in Liberty version 21.0.0.12, the Enterprise JavaBeans feature (ejb-3.2) is renamed as the Jakarta Enterprise Beans feature (enterpriseBeans-4.0). Applications that are written by using the javax package name can continue to use the ejb versions of the features and applications that use the jakarta package name must use the enterpriseBeans version of the features. For more information about Jakarta EE 9 feature name changes, see Jakarta EE 9 feature updates on the Open Liberty website.

Four API methods were removed in the Jakarta Enterprise Beans 4.0 specification. When you migrate an application from an earlier version of the specification, the following methods must be removed or replaced with the suggested alternative.
javax.ejb.EJBContext.getCallerIdentity()
use the getCallerPrincipal() method instead.
javax.ejb.EJBContext.getEnvironment()
Use JNDI lookup in java:comp/env instead.
javax.ejb.EJBContext.isCallerInRole(java.security.Identity)
Use the isCallerInRole(String) method instead.
javax.ejb.SessionContext.getMessageContext()
No replacement; this method is for the JAX-RPC API, which Liberty does not support.
The following features provide the minimum set of capabilities for the Enterprise Beans APIs.
ejbLite
enterpriseBeansLite

This feature enables the lite subset of the enterprise beans technology as defined in the Enterprise Beans specification. This subset includes support for local session beans that are written to the Enterprise Beans 3.x APIs. Beginning with the ejbLite-3.2 feature, the subset also includes support for nonpersistent enterprise bean timers and asynchronous local interface methods.

Other than enabling the feature in the server.xml file, no additional configuration is required for this feature.

mdb

This feature enables the message-driven bean subset of the enterprise beans technology, which is similar to the support that the ejbLite and enterpriseBeansLite features enable for session beans. The feature does not enable session beans, so if both session and message-driven beans are needed, then both features need to be enabled in the server.xml file.

Note: Enterprise Beans 2.x API entity beans are not supported by Liberty. For persistence, the Java Persistence API (JPA) must be used instead.
The following features provide extensions to the core Enterprise Beans features, which, when they are combined, support the full set of Enterprise Beans APIs:
ejbHome
enterpriseBeansHome

This feature enables support of the Enterprise Beans 2.x APIs, specifically, support for the javax.ejb.EJBLocalHome interface. The javax.ejb.EJBHome interface is also supported when combined with the ejbRemote or enterpriseBeansHome features. Since this feature is not useful without the corresponding ejbLite or enterpriseBeansLite feature, enabling this feature automatically enables the corresponding ejbLite or enterpriseBeansLite feature.

Other than enabling the feature in the server.xml file, no additional configuration is available for this feature, unless application security (for example, the appSeciruty-2.0 feature) is also enabled. When application security is enabled, more security configuration is required. For more information, see Getting started with security in Liberty.

ejbPersistentTimer
enterpriseBeansPersistentTimer

This feature enables support for persistent Enterprise Beans timers. Enabling this feature automatically enables the corresponding ejbLite feature.

In addition to enabling this feature in the server.xml file, a data source must also be configured to provide the persistent store for the timers. By default, the DefaultDataSource data source is used.

ejbRemote
enterpriseBeansRemote

This feature enables support for remote Enterprise Beans interfaces. Enabling this feature automatically enables the corresponding ejbLite feature.

Other than enabling the feature in the server.xml file, no additional configuration is required for this feature.

The following feature provides a convenient way to enable the full set of Enterprise Beans APIs:
ejb
enterpriseBeans

This feature enables all of the core and extension features for the specification level of the configured feature. For example, ejb-3.1 enables ejbLite-3.1 and mdb-3.1. This feature provides no additional support beyond what is provided by enabling all of the core and extension Enterprise Beans features.

Other than enabling the feature in the server.xml file, no additional configuration is required for this feature beyond what is required for the ejbPersistentTimer, enterpriseBeansPersistentTimer, ejbRemote, and enterpriseBeansRemote features.

The following convenience features include Enterprise Beans features.
webProfile
This feature enables all features that are required for the Java EE or Jakarta EE Web Profile, which includes either the ejbLite or enterpriseBeansLite feature.
javaee
jakartaee
This feature enables all features that are required for the Java EE or Jakarta EE Full Profile, which includes either the ejb or enterpriseBeans convenience feature.

Procedure

Enable the feature in the server.xml file, as shown in the following example.
<featureManager>
    <feature>ejbLite-3.2</feature>
</featureManager>
<featureManager>
    <feature>enterpriseBeansLite-4.0</feature>
</featureManager>