+

Search Tips   |   Advanced Search

EJB 3.0 considerations


When using EJBs 3.0 modules, keep in mind the following considerations.

 

Version 7.0 does not support entity beans in EJB 3.0-level modules

IBM® WebSphere® Application Server V7.0 does not support the use of bean managed persistence (BMP) and container managed persistence (CMP) entity beans in EJB 3.0-level modules. BMP entity beans are supported in the Feature Pack for EJB 3.0, although CMP beans are not. EJB entity beans may still be used on V7.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.0-level modules fail to install on V7.0. An EJB JAR file is considered to be an EJB 3.0 module when either of the following are true:

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

 

Annotations

Consider if we will use annotations versus deployment descriptors, or both. See the topic "EJB 3.0 metadata annotations" for more information about annotations.

 

EJB module

WAS V 7.0 supports EJB module JAR files with an ejb-jar.xml deployment descriptor declared at the 1.1, 2.0, 2.1, or 3.0 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.0 beans must be declared to be at the EJB 3.0 level. This can be accomplished either by setting the ejb-jar.xml deployment descriptor level to 3.0, 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.0-specific functions such as annotation scanning or resource injection will be performed.

Entity beans are not supported in EJB 3.0 level modules. You must place any entity beans in EJB modules at the 2.1 or earlier level.

 

Java EE application client module

WAS ND v7.0 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.

EJB 3.0 does not support the injection of an enterprise bean that creates a new enterprise bean of itself. Do not inject an enterprise bean that creates a new enterprise bean of itself.

Define an ejb-ref reference to an EJB 3.0 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.0 business interface. EJB 3.0 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 be specified. Therefore, include the <home></home> stanza in the ejb-ref definition, but specify a null value as shown in the example below. For the value of the <remote> stanza, specify the EJB 3.0 business interface class name. Finally, when you set the binding value, either during application install or through tooling, specify the location where the EJB 3.0 business interface was bound. For example, the ejb-ref in the client component's application-client.xml file will look similar to the following:

<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 similar to the following. A default EJB binding pattern is used here; the default EJB binding conventions are described in the topic, "EJB 3.0 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>





Related concepts


EJB 3.0 application bindings overview

 

Related tasks


Task overview: Storing and retrieving persistent data with the Java Persistence API (JPA)