and message-driven beans—can subscribe to transactions declaratively. This often puts
the application designers in a dilemma when they get down to devising strategies for
transaction management. Consider the cases when your session bean accesses a number
of entity beans or when a message-driven bean invokes remote methods on a session
bean. Even with declarative Java EE transaction support, it becomes difficult to make
crucial decisions such as where to start a transaction, how to propagate a transaction,
and where to end it.
Sometimes Java EE applications are required to support non-web-based clients such
as Java Swing-based desktop software. These clients more often than not resort to client-
managed transactions. This is done programmatically with JTA. This, however, dilutes the
core goal of the Swing clients to act only as the view tier. This also results in multiple fine-
grained calls to the business logic on the server, which leads to a surge in network traffic.
This also greatly reduces the benefits of server-based distributed computing. Developing,
testing, and maintaining applications with client tier programmatic transaction are com-
In Chapter 4, I mentioned a client of eInsure who wanted us to deploy the entire
application on Apache Tomcat, which is a web server and servlet container. Tomcat does
not have an EJB container. So, the EJBs did not work in Tomcat, and there was no transac-
tion management support. An immediate option was to use JDBC-based transaction
support. But this would be cumbersome and would require a lot of code to be written as
well as refactored. Another solution was to use open source transaction monitors such as
ObjectWeb JOTM or Atomikos Essentials. But using them would pose the same problems
as with client-managed transactions.
• Avoid client-managed transactions wherever possible.
• Support declarative transaction management to be applied transparently.
• Declarative transaction management should work outside the EJB container
Deploy a domain service owner transaction to declaratively apply transactions both in
and out of the EJB container.