+

Search Tips   |   Advanced Search

Change applications to WebSphere "version specific" setRollbackOnly behavior

Use this task to allow post-EJB 3.0 applications to exhibit the pre-EJB 3.0 behavior and to allow pre-EJB 3.0 applications to exhibit post-EJB 3.0 behavior. The steps in this task that provide this processing behavior are based on a very specific processing scenario, which is explained in the About this task section.

Processing Scenario: The basis for this task is the following processing scenario.

An EJB method is invoked which starts a global transaction. Within the execution of this method another EJB method is invoked that continues to run within the same transaction. During the execution of this method, the setRollbackOnly() method is invoked. The EJB Container behavior when this scenario is encountered is dictated by the EJB Specification. However, this behavior was required to change in the WebSphere Application Server for EJB 3.0 support.

Section 13.6.2.8 of JSR 220: Enterprise JavaBeans™,Version 3.0 EJB Core Contracts and Requirements document, as well as previous versions of the EJB specification, indicates that

"If the container initiated the transaction immediately before dispatching the business method to the instance (as opposed to the transaction being inherited from the caller), the container must note that the instance has invoked the setRollbackOnly method. When the business method invocation completes, the container must roll back rather than commit the transaction. If the business method has returned normally or with an application exception, the container must pass the method result or the application exception to the client after the container performed the rollback." Also, section 14.3.11 states: "However, the container should not throw the javax.ejb.EJBException or java.rmi.RemoteException or if the container performs a transaction rollback because the instance has invoked the setRollbackOnly method on its EJBContext object. In this case, the container must rollback the transaction and pass the business method result or the application exception thrown by the business method to the client."

Historically, the WAS has interpreted the preceding sections of the specification to dictate that the setRollbackOnly behavior should only applied if the transaction was marked as RollbackOnly within the method that began the transaction. However, the Compatibility Test Suite for the EJB 3.0 specification requires that a transaction marked as RollbackOnly exhibit the given setRollbackOnly behavior, regardless of whether the transaction was marked as RollbackOnly within the method that began the transaction, or within another method within the same transaction that was invoked from the original EJB method.

To illustrate this requirement, consider the following example:

Behavior prior to EJB 3.0: Since the transaction is not initiated with the B.bob() method, a TranactionRolledbackException is thrown to A.art() and eventually to the client application.

Behavior introduced in EJB 3.0 and beyond: Method B.bob() returns normally to method A.art(). Method A.art() performs a rollback on the transaction and return the results to the client with no exception thrown to the client application, as indicated by the EJB specification.

Since this processing introduces a change in behavior for applications that are migrated to EJB 3.0 or beyond from a previous version, the following JVM system properties are available to change this behavior to suit your requirements:

The values of these properties are set to the application names (appName1:appName2:appName3) that need to demonstrate the desired behavior.


Tasks

  1. Open the administrative console.

  2. Select Servers.

  3. Select Server Types.

  4. Select WebSphere application servers.

  5. Select the server to configure.

  6. Under Server infrastructure, select Java and Process Management > Process Definition.

  7. Under Additional properties, select Java virtual machine > Custom properties > New.

  8. In the Name entry field, type the JVM system property.

    com.ibm.websphere.ejbcontainer.limitSetRollbackOnlyBehaviorToInstanceFor

    or

    com.ibm.websphere.ejbcontainer.extendSetRollbackOnlyBehaviorBeyondInstanceFor

  9. In the Value entry field, type (appName1:appName2:appName3....). . Names of the application(s) that the behavior should apply.

  10. Select OK.

  11. Save the configuration.

  12. Restart the server.