Do not use UserTransaction interface from CMT beans

The Java EE specification indicates that container-managed transaction (CMT) beans might not access the UserTransaction object. However, WebLogic supports the UserTransaction lookup.

This rule flags the following type of code:

WebLogic UserTransaction Lookup
UserTransaction xact = ctx.lookup("javax.transaction.UserTransaction");

or

UserTransaction xact = ctx.lookup("weblogic.transaction.UserTransaction");

Access to UserTransaction is not allowed in the bean where it is being flagged. Your solution depends on what the code is attempting to do with the UserTransaction. Examine the use of UserTransaction to determine how the code must be changed or if the reference can be removed.

Alternatives to UserTransaction include using the UOWManager. Lookup for this manager also uses a JNDI lookup; for example:

UOWManager Lookup

UOWManager uowMgr = ctx.lookup("java:comp/websphere/UOWManager");

Another approach might be to use the SessionSynchronization interface, which gives you access to the afterBegin, beforeCompletion, and afterCompletion methods. The method, beforeCompletion, gives you an opportunity to revert to the previous version of the transaction, in the case of an error.