Enterprise Java application servers natively provide JTA (Java Transaction API) support, which enables distributed transaction, which is also known as global transaction, spanning multiple resources, applications and servers. Traditionally, Enterprise Java Beans (EJB) and Message Driven Beans (MDB) were used for container-managed transactions (CMT), which is based on JTA and JNDI. JTA transaction management is resource-intensive; its exception handling is based on checked exceptions and so is not developer-friendly. Moreover, unit testing is hard with EJB CMT.
For those who do not want to use resource-intensive JTA transactions, a local transaction is another available option, and one that allows you to programmatically enforce resource-specific transactions using APIs such as JDBC. Although relatively easy to use, it is limited to a single resource, as multiple resources cannot participate in a single transaction. Moreover, local transactions are often invasive...