O'Reilly logo

Enterprise JavaBeans, Second Edition by Richard Monson-Haefel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

EJB 1.0: Exceptions and Transactions

In EJB 1.0, the impact of exceptions on transactions largely depends on who initiates the transaction. A transaction that is started automatically when a bean method is invoked is a container-initiated transaction. Specifying the TX_REQUIRES_NEW transaction attribute, for example, always results in a container-initiated transaction. A TX_REQUIRED method invoked by a non-transactional client also results in a container-initiated transaction. A transaction that is started explicitly using JTA (on the client or in a TX_BEAN_MANAGED bean) is not a container-initiated transaction.

With container-initiated transactions, any exception thrown during a transaction can cause the transaction to roll back. The impact of an exception thrown during a transaction depends on the type of exception (checked or unchecked) and the transaction attribute of the bean method throwing the exception. This section examines the different combinations of exceptions (checked or unchecked) and transaction attributes and their combined affect on transactional outcomes.

Container-Initiated Transactions

Any exception (application exception, unchecked exception, or RemoteException) not handled within the scope of the container-initiated transaction causes the container to roll back the entire transaction.

Note

An exception that is not handled within the scope of container-initiated transaction is an exception that is propagated, through the call stack, beyond the bean method ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required