Implement EJB 3.x applications
Use this task when we are implementing EJB 3.x applications.
Based on the EJB specification, enterprise beans are Java components that typically implement the business logic of Java Platform, Enterprise Edition (JEE) applications as well as access data. IBM WebSphere Application Server provides broad support for enterprise beans, including the EJB 2.x and EJB 3.x specifications. The EJB 3 specification simplifies the development of business logic and data handling for enterprise applications. We can assemble the beans into one or more EJB 3.x modules using one of the assembly tools.
The EJB 3.0 specification has justifiably been called the most important upgrade to the Java Platform, Enterprise Edition 5 (Java EE 5) programming model. The EJB 3.0 specification represents simplification and streamlining of the business logic and persistence programming models used in Java EE. While the Java Persistence API (JPA) replacement is called an entity class, it should not be confused with entity enterprise beans. A JPA entity is not an enterprise bean and is not required to run in an EJB container.
The EJB specification only requires local client views to be supported for EJBs packaged within the same application. This includes local homes, local business interfaces, and the no-interface view. WAS permits access to local client views to EJBs packaged within a separate application with some restrictions:
- The local interface and all parameter, return, and exception types used by the local interface must be visible to the class loader of both the calling application and the target EJB application. We can ensure this by either using a shared library associated with a server class loader or using an isolated shared library associated with both applications. Read the Creating shared libraries topic for more information.
- When the target EJB application is stopped, any cached references to the EJB must be refreshed. We can either:
- Restart the calling application. The simplest solution is to restart the calling application whenever you restart a target EJB application on which it relies.
- Obtain a new reference from JNDI. By default, JNDI lookups from the java namespace are cached, and the cache must either be disabled or cleared to obtain a new reference. Read the Developing applications that use JNDI topic for more information.
EJB method invocations throw com.ibm.websphere.ejbcontainer.EJBStoppedException when the target EJB application has been stopped. If we have cached the EJB reference in an instance variable using either @EJB injection or JNDI lookup, then we can catch this exception and refresh the EJB reference by performing a non-cached lookup.
Complete the following procedure to implement EJB 3.x application in WAS, including tuning and troubleshooting tips.
Tasks
- Migrate enterprise bean code.
- There are no migration issues associated with using EJB 3.x beans. Existing applications continue to run as-is and compile without error. The EJB 3.0 and 3.1 specifications have deprecated the use of EJB 1.1 style entity beans. We are encouraged to start migrating to Java Persistence API (JPA) or JDBC as a replacement for entity beans.
- Develop EJB 3.x applications.
- Design a Java EE application and the enterprise beans that it needs. Before developing entity beans with CMP, read the topic, Concurrency control. Keep in mind that EJB 3.x modules do not support entity beans. We must continue to place entity beans in your EJB 2.x-level modules.
- Assemble EJB 3.x applications.
- Assemble an EJB 3.x module to contain enterprise beans and related code artifacts. Group web components, client code, and resource adapter code in separate modules. After the EJB module is assembled, install it as a stand-alone application or combine it with other modules into an enterprise application.
- Deploy the EJB 3.x applications.
- When we deploy an EJB module, we install that module on a server configured to support deployed modules. Assemble one or more EJB modules, assemble one or more web modules, and assemble them into a Java EE application.
- Administer EJB 3.x applications.
- Manage EJB containers, administer session beans and entity beans.
- Secure EJB 3.x applications.
- We can protect enterprise bean methods by assigning security roles to them. Before we assign security roles, we need to know which EJB methods need protecting and how to protect them.
- Tune EJB 3.x applications.
- If we use applications that affect the size of the EJB container cache, it is possible that the performance of the applications can be impacted by an incorrect size setting. It is important to know that entity beans are not supported in an EJB 3.x module. One of the steps in tuning your EJB container to optimum performance levels is to fine-tune the EJB cache.
- Troubleshoot EJB 3.x applications.
- Use these troubleshooting tips for problems related to accessing enterprise beans.
We have implemented EJB 3.x applications on WAS.
Change applications to WebSphere "version specific" setRollbackOnly behavior