Feature Pack for EJB 3.0 considerations

When using the Feature Pack for EJB 3.0, keep in mind the following considerations.

Annotations

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

EJB component

The Feature Pack for EJB 3.0 fully supports all functions described in the EJB 3.0 Core Contracts specification. No special limitations need to be taken into account for EJB 3.0 components running on the Feature Pack for EJB 3.0.

EJB module

The feature pack fully 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.

EJB modules that contain EJB 3.0 beans must be declared to be at the EJB 3.0 level when running on the feature pack. 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 is performed.

EJB modules that contain container-managed persistence (CMP) entity beans must not be declared to be at the EJB 3.0 level when running on the feature pack. Modules at the EJB 3.0 level, either explicitly declared in the ejb-jar.xml descriptor, or implicitly by the absence of ejb-jar.xml in the module, cannot contain CMP entity beans, when running on the feature pack. If your EJB 3.0 application uses CMP entity beans, place them in an EJB module with a module level lower than 3.0.

Application

The feature pack supports Enterprise Application Archive (EAR) modules with an application.xml deployment descriptor declared at the Java 2 Platform, Enterprise Edition (J2EE) 1.4 level, which is the same base J2EE level that WebSphere Application Server V6.1 supports. Additionally, it supports EAR archives that do not contain an application.xml deployment descriptor at all -- in that scenario, a J2EE EAR file deployment descriptor is generated for you.

The feature pack supports EAR archives containing EJB modules at the EJB 3.0 level or earlier, Web modules at the servlet 2.4 level or earlier, and application-client modules at the J2EE 1.4 level or earlier. The feature pack supports application.xml descriptors in EAR archives at the J2EE 1.4 level or earlier only, but the application.xml descriptor can still refer to EJB modules at the EJB 3.0 level.

Java Persistence API (JPA)

The Feature Pack for EJB 3.0 provides full support for all functions described in the EJB 3.0 Persistence specification, also referred to as the JPA specification. No special considerations need to be taken into account for applications using JPA functionality in the feature pack.

Web module

The feature pack provides support for Web components at the J2EE 1.4-appropriate specification levels for servlets and Java Server Pages (JSPs).

Even though support for Web components remains at the J2EE 1.4 level, the feature pack does support injection of EJB references and other injections into servlet components if the injection is defined through an @EJB annotation. The 2.4 level of the web.xml deployment descriptor format does not support injection, therefore, servlets that run on the feature pack can only be performed through annotations.

In the feature pack, injection is supported only within servlets, filters, and servlet listeners.

Creating a local or remote reference to EJB 3.0 business interface from a servlet 2.4 descriptor

It is possible to define an ejb-ref or ejb-local-ref from a servlet 2.4 web.xml descriptor that points to an EJB 3.0 remote or local business interface.

Since EJB 3.0 business interfaces are accessed directly without the use of a home, yet the ejb-ref and ejb-local-ref elements in servlet 2.4 requires that a home or local-home interface type be specified, include the <home></home> or <local-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> or <local> 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, an ejb-ref to an EJB 3.0 business interface in your servlet component's web.xml file would 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-web-bnd.xmi file will look 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 application bindings support."
<ejbRefBindings xmi:id="EjbRefBinding_1" jndiName="EJB3App/EJB3Mod.jar/MyBean#com.ejbs.business.interface.class.name">
	<bindingEjbRef href="WEB-INF/web.xml#EjbRef_1"/>
</ejbRefBindings>
Alternatively, the same example using an ejb-local-ref instead of an ejb-ref would look like this:
<ejb-local-ref id="EjbLRef_1">
	<ejb-ref-name>java_comp-env_name_of_ref</ejb-ref-name>
	<ejb-ref-type>Session</ejb-ref-type>
	<local-home></local-home>
	<local>com.ejbs.business.interface.class.name</local>
</ejb-local-ref>
The binding in ibm-web-bnd.xmi would be set up the same as for the ejb-ref.

Java EE application client module

The feature pack provides support for Java EE application client modules at the J2EE 1.4 specification level. Additionally, it supports injection of EJB references into client components if the injection is defined through the @EJB annotation.

The 1.4 level of the application-client.xml deployment descriptor format does not support injection, therefore, injection from client components running on the feature pack can only be performed through annotations.

Attention: The feature pack does not support the injection of an enterprise bean that creates a new enterprise bean of itself.

Defining an ejb-ref reference to an EJB 3.0 business interface from a J2EE 1.4 client component descriptor

It is possible to define an ejb-ref from a 1.4-level 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 J2EE 1.4 requires that a home interface type be specified. Therefore, you must 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 your 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>

Feature Pack for Web Services

Although the Feature Pack for EJB 3.0 can coexist with the Feature Pack for Web Services with no issues, the two feature packs do not provide cross-feature-pack integration.

The Feature Pack for EJB 3.0 does not implement the functions of the @WebService or @WebMethod annotations on EJB 3.0 stateless session beans, although it does tolerate the presence of these annotations if the Feature Pack for Web Services is also installed nor does it support injection of Web services references. However, it is still possible to invoke EJB 3.0 beans indirectly, by defining a Plain Old Java Object (POJO)-based Java API for XML Web Services (JAX-WS) service implementation and placing code in the POJO that looks up and then invokes the target EJB 3.0 bean.




Related concepts
EJB 3.0 application bindings overview
What is new in the Version 6.1 Feature Pack for EJB 3.0
Related tasks
Task overview: Storing and retrieving persistent data with the Java Persistence API (JPA)
Reference topic Reference topic    

Terms and conditions for information centers | Feedback

Last updatedLast updated: Aug 31, 2013 2:56:59 AM CDT
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=pix&product=was-nd-dist&topic=rejb_consid
File name: rejb_consid.html