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.
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.
- 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.
- 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
andenterpriseBeansLite
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.
- 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
orenterpriseBeansHome
features. Since this feature is not useful without the correspondingejbLite
orenterpriseBeansLite
feature, enabling this feature automatically enables the correspondingejbLite
orenterpriseBeansLite
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.
- 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
enablesejbLite-3.1
andmdb-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
, andenterpriseBeansRemote
features.
- webProfile
- This feature enables all features that are required for the Java EE or Jakarta EE Web Profile,
which includes either the
ejbLite
orenterpriseBeansLite
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
orenterpriseBeans
convenience feature.
Procedure
<featureManager>
<feature>ejbLite-3.2</feature>
</featureManager>
<featureManager>
<feature>enterpriseBeansLite-4.0</feature>
</featureManager>