

Gone are the days when the only alternative to using EJB CMT or JTA was to write code with local transactions such as those on JDBC connections, and face a hefty rework if you need that code to run within global, container-managed transactions. The Spring Framework gives you the choice of when to scale your application to a fully loaded application server. Of course, you may need other application server capabilities such as Java Message Service (JMS) and Java EE Connector Architecture (JCA).

Standalone transaction managers such as Atomikos Transactions and JOTM are other options. Many high-end applications use a single, highly scalable database (such as Oracle RAC) instead.

Typically you need an application server’s JTA capability only if your application needs to handle transactions across multiple resources, which is not a requirement for many applications. In fact, even if your application server has powerful JTA capabilities, you may decide that the Spring Framework’s declarative transactions offer more power and a more productive programming model than EJB CMT. In particular, you do not need an application server simply for declarative transactions through EJBs. The Spring Framework’s transaction management support changes traditional rules as to when an enterprise Java application requires an application server. The negatives of EJB in general are so great that this is not an attractive proposition, especially in the face of compelling alternatives for declarative transaction management.ĭo you need an application server for transaction management? Also, it is only available if one chooses to implement business logic in EJBs, or at least behind a transactional EJB facade. The significant downside is that CMT is tied to JTA and an application server environment. It removes most but not all of the need to write Java code to control transactions. EJB CMT removes the need for transaction-related JNDI lookups, although of course the use of EJB itself necessitates the use of JNDI. Previously, the preferred way to use global transactions was via EJB CMT ( Container Managed Transaction): CMT is a form of declarative transaction management (as distinguished from programmatic transaction management). Obviously the use of global transactions would limit any potential reuse of application code, as JTA is normally only available in an application server environment. Furthermore, a JTA UserTransaction normally needs to be sourced from JNDI, meaning that you also need to use JNDI in order to use JTA. The application server manages global transactions through the JTA, which is a cumbersome API to use (partly due to its exception model). Global transactions enable you to work with multiple transactional resources, typically relational databases and message queues.
