Network Deployment (Distributed operating systems), v8.0 > Reference > Developer best practices


EJB 3.x module considerations

When using EJB 3.x modules, keep in mind the following considerations.


v8.0 does not support 1.x and 2.x entity beans in EJB 3.x-level modules

IBMWAS v8.0 does not support the use of 1.x and 2.x bean managed persistence (BMP) and container managed persistence (CMP) entity beans in EJB 3.x-level modules. EJB entity beans can be used on V8.0, but they must be packaged in an EJB 2.1 or earlier-level module.

Java EE applications that are packaged with EJB entity beans in EJB 3.x-level modules fail to install on v8.0.

An EJB JAR file is considered to be an EJB 3.x module when either of the following are true:

You need to repackage your EJB 3.x modules using EJB 2.x and earlier modules. Otherwise, the installation of any applications that contain entity beans fail.


Annotations

Consider using annotations versus deployment descriptors, or both. See the topic EJB 3.x metadata annotations for more information about annotations.


EJB module

WAS v8.0 supports EJB module Java archive (JAR) files with an ejb-jar.xml deployment descriptor declared at the 1.1, 2.0, 2.1, 3.0, or 3.1 level, or with no ejb-jar.xml deployment descriptor present. If no deployment descriptor is present, the EJB module is assumed to be at the 3.0 level or greater.

EJB modules that contain EJB 3.x beans must be declared to be at the EJB 3.0 or EJB 3.1 level. This can be accomplished either by setting the ejb-jar.xml deployment descriptor level to 3.0 or 3.1, or ensuring that the module does not contain an ejb-jar.xml deployment descriptor. If the module level is 2.1 or earlier, no EJB 3.x-specific functions such as annotation scanning or resource injection is performed.

Entity beans are not supported in EJB 3.x level modules. We must place any entity beans in EJB modules at the 2.1 or earlier level.

If to package an EJB 3.x module with a deployment descriptor, there are several ways to do it. Package an EJB 3.x module with an EJB 3.x style session and message-driven beans exclusively; with an EJB 2.1 style session and message-driven beans exclusively, or a combination of 2.1 and 3.x style beans. The XML deployment descriptor must be a v3.0 or 3.1 deployment descriptor. It is required that 2.1 entity beans are packaged in modules with 2.1 deployment descriptors. EJB modules that contain EJB 3.x beans must be at the EJB 3.0 or EJB 3.1 specification level when running on the product. Prepare the EJB module to support EJB 3.x beans, by setting the ejb-jar.xml deployment descriptor level to 3.0 or 3.1, or you can make sure that the module does not contain an ejb-jar.xml deployment descriptor. If the module level is EJB 2.1 or earlier, no EJB 3.x functions, including annotation scanning or resource injection is performed at run time.


Java EE application client module

The product provides support for Java EE application client modules. Additionally, it supports injection of EJB references into client components if the injection is defined through the @EJB annotation.

Attention: EJB 3.x does not support the injection of an enterprise bean that creates an enterprise bean of itself. Do not inject an enterprise bean that creates an enterprise bean of itself.

Define an ejb-ref reference to an EJB 3.x business interface from a Java EE client component descriptor

It is possible to define an ejb-ref from an application-client.xml descriptor that points to an EJB 3.x business interface. EJB 3.x business interfaces are accessed directly without the use of a home, yet the ejb-ref element in Java EE requires that a home interface type is specified. Therefore, include the <home> </home> stanza in the ejb-ref definition, but specify a null value as shown in the example. For the value of the <remote> stanza, specify the EJB 3.x business interface class name. Finally, when you set the binding value, either during application installation or through tooling, specify the location where the EJB 3.x business interface was bound.

For example, the ejb-ref in your client component application-client.xml file looks like the following code sample:

<ejb-ref id="EJBRef_1">
<ejb-ref-name>java_comp-env_name_of_ref
</ejb-ref-name>
<ejb-ref-type>Session
</ejb-ref-type>
<home>
</home>
<remote>com.ejbs.business.interface.class.name
</remote>
</ejb-ref> 
The corresponding section of the ibm-application-client-bnd.xmi file looks like the following code sample. A default EJB binding pattern is used here; the default EJB binding conventions are described in the topic, EJB 3.x applications binding support.
<ejbRefBindings xmi:id="EjbRefBinding_1"
         jndiName=EJB3App/EJB3Mod.jar/MyBean##com.ejbs.business.interface.class.name">
<bindingEjbRef href="application-client.xml#EjbRef_1"/>
</ejbRefBindings>

EJB 3.0 and EJB 3.1 application bindings overview
Task overview: Storing and retrieving persistent data with the JPA API
Change applications to WebSphere "version specific" setRollbackOnly behavior

+

Search Tips   |   Advanced Search