Which three are possible causes for the containers behavior?

While excepting a business method in a stateless session bean the container rolls back the
methods transaction. Which three are possible causes for the containers behavior? (Choose
three.)

While excepting a business method in a stateless session bean the container rolls back the
methods transaction. Which three are possible causes for the containers behavior? (Choose
three.)

A.
The bean uses container-managed transactions and invokes EJBContext.setRollbackOnly.

B.
The bean uses container-managed transactions and invokes EJBContext.getRollbackOnly.

C.
The business method throws a java.lang.NullPointerException.

D.
The business method throws a checked exception of a class type that is marked with the
@ApplicationException annotation with the rollback element value true.

E.
The business method throws a unchecked exception of a class type that is marked with the
@ApplicationException annotation with the rollback element value true.

F.
The bean uses container-managed transactions and throws a checked exception of a class type
that is marked with the @ApplicationException annotation with the rollback element value false.

Explanation:
A:setRollbackOnly
Mark the current transaction for rollback. The transaction will become permanently marked for
rollback. A transaction marked for rollback can never commit. Only enterprise beans with
container-managed transactions are allowed to use this method.
Note:
* In a stateless session bean with bean-managed transactions, a business method must commit or
roll back a transaction before returning.
*Bean-Managed Transactions
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.
* (incorrect)Unchecked runtime exceptions represent conditions that, generally speaking, reflect

errors in your program’s logic and cannot be reasonably recovered from at run time.
Incorrect:
B:getRollbackOnly
Test if the transaction has been marked for rollback only. An enterprise bean instance can use this
operation, for example, to test after an exception has been caught, whether it is fruitless to
continue computation on behalf of the current transaction. Only enterprise beans with containermanaged transactions are allowed to use this method.



Leave a Reply 3

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


Oscar

Oscar

A, C, D, E… something is wrong…

Andrei

Andrei

A,C,D, E

What is the difference between D and E?