Global transactions
If an application uses two or more resources, an external transaction manager is needed to coordinate the updates to both resource managers in a global transaction.
Global transaction support is available to Web and enterprise bean J2EE components and, with some limitation, to application client components. Enterprise bean components can be subdivided into beans that exploit container-managed transactions (CMT) or bean-managed transactions (BMT).
BMT enterprise beans, application client components, and Web components can use the Java Transaction API (JTA) UserTransaction interface to define the demarcation of a global transaction. To obtain the UserTransaction interface, use a JNDI lookup of java:comp/UserTransaction, or use the getUserTransaction method from the SessionContext object.
The UserTransaction interface is not available to CMT enterprise beans. If CMT enterprise beans attempt to obtain this interface, an exception is thrown, in accordance with the EJB specification.
Ensure that programs that perform a JNDI lookup of the UserTransaction interface use an InitialContext that resolves to a local implementation of the interface. Also, ensure that such programs use a JNDI location that is appropriate for the EJB version.
The JNDI location of the UserTransaction interface is specified in the EJB V1.1 specification. Before this specification, the JNDI location of the UserTransaction interface was defined by each implementer of an EJB container. For WAS, the location is as follows:
- Versions of WAS up to, and including, Version 3.5.x (without EJB V1.1) bind the UserTransaction interface to a JNDI location of jta/usertransaction.
- WAS V4, and later releases, bind the UserTransaction interface at the location defined by EJB V1.1, that is, java:comp/UserTransaction.
- WAS V5, and later releases, do not provide the jta/usertransaction binding within Web and EJB containers to applications at a J2EE level of V1.3 or later. For example, from EJB Version2.0, applications can use only the java:comp/UserTransaction location.
A Web component or enterprise bean (CMT or BMT) can get the ExtendedJTATransaction interface through a lookup of java:comp/websphere/ExtendedJTATransaction. This interface provides access to the transaction identity and a mechanism to receive notification of transaction completion.
Related concepts
Extended JTA support
Local transaction containment (LTC)
Client support for transactions
Transaction support in WAS