What is the expected result of this method invocation assuming control reaches Line 12?

FooBean and BarBean are both EJB 3.x stateless session beans with bean-managed transaction
demarcation. The business method foo in FooBean starts a UserTransaction and invokes the
business method bar in BrBean.
Given:

What is the expected result of this method invocation assuming control reaches Line 12?

FooBean and BarBean are both EJB 3.x stateless session beans with bean-managed transaction
demarcation. The business method foo in FooBean starts a UserTransaction and invokes the
business method bar in BrBean.
Given:

What is the expected result of this method invocation assuming control reaches Line 12?

A.
FooBean.foo method receives MyAppException.

B.
The container discards the BarBean bean instance.

C.
FooBean.foo method receives a javax.ejb.EJBException that wraps MyAppException.

D.
FooBean.foo method receives javax.transaction.TransactionRolledbackException.

Explanation:
The transaction will roll back.
Note:
*In bean-managed transaction demarcation, the code in the session or message-driven bean
explicitly marks the boundaries of the transaction. Although beans with container-managed
transactions require less coding, they have one limitation: When a method is executing, it can be
associated with either a single transaction or no transaction at all. If this limitation will make coding
your bean difficult, you should consider using bean-managed transactions.
Reference:The Java EE 5 Tutorial,Bean-Managed Transactions



Leave a Reply 5

Your email address will not be published. Required fields are marked *


JavaBatman

JavaBatman

D is right solution!