Two-phase commit transactions

Two-phase commit (XA) transactions are disabled in Liberty buildpacks for Cloud Foundry environments. By default, the Liberty transaction manager writes the transaction log file to the local file system. Because the local file system is ephemeral in cloud platforms, the transaction log file is not available after an application or the Java virtual machine crashes. Although the transaction manager can be configured to use a database service to store the transaction logs, cloud platforms automatically create a completely new instance of the application after a crash. As a result, the transaction manager cannot identify which particular log to use to recover the transactions of the failed instance.

Two-phase commit transactions can be in use through EJB beans or the application's use of the javax.transaction.UserTransaction class. To successfully run in a Cloud Foundry environment, verify whether your application requires XA transactions.

By default, Enterprise JavaBeans (EJB) beans are container-managed and have a Required transaction attribute, which means they use JTA transactions. JTA transactions that span a single resource are fully supported. JTA transactions that span multiple resources require two-phase commit which is not supported in Cloud Foundry environments.

In Java code, the following explicit annotations indicate use of JTA transactions:

In the ejb-jar.xml file, the following explicit elements indicate use of JTA transactions:

Note: If your application does not use the javax.transaction.UserTransaction class, and all of your application EJB Beans are bean managed, or container managed with transaction attributes of "Never" or "NotSupported", then your application is not using XA transactions, and the flagging of this rule can be ignored.

The following explicit annotations or elements indicate that an EJB bean is not using XA transactions: