Given: Bean A with transaction attributes of "RequiresNew" for all its methods. Bean B with transaction attributes of "Supports" for all its methods. A client having a transaction context calls a method mA() on bean A, which in turns calls a method mB() on Bean B. Assuming all invocations are local, which of the following statements is correct if mB() encounters a system exception?
Select 2 correct options
a The client's transaction will be marked for roll back.
b The client will get a javax.ejb.EJBException but it can continue with the same transaction.
c The client will get a javax.ejb.TransactionRolledbackLocalException
d mA() will get a javax.ejb.TransactionRolledbackLocalException
e The bean A instance will NOT be discarded.
f Changes made to the database by mA(), will be commited.
Hi, I think the correct answers are d & e. For bean B, the client is bean A.Since bean A is running in a new transaction and bean B runs in the same transaction, when exception occurs in bean B, it would be bean A which receives the javax.ejb.TransationRolledbackLocalException.Also since the exception has occurred in bean B, there is no need to discard the instance of bean A. Option a is not correct because the exception doesnot occur in client transaction Option b is not correct because for bean B, the client is bean A Option c is not correct for the same reason Option f is not correct because the exception occurred when bean B was running in the transaction context of bean A Please correct me if the above reasoning is wrong
May be you are correct, but what i think is since the transaction in which Bean A was running has been marked to rollback, there is no reason for container not discarding beanA.
Option B seems to be correct because though beanA is client to beanB but the component who invoked mA() is client to beanA who would get ejbException and that is the client which is reffered to in option B
E will be wrong option to pick ..since the exception is generated in TxA context (transaction A). In this case, the instance will be discarded. you dont want to keep the values even if you get a transaction exception in the same transaction context, or else it will keep your system in inconsitent state (may be dirty values).
The option A is wrong because, client get the exception(javax.ejb.EJBException) notice from transaction context A but it is upto the client to decide to continue the transaction or not. So the option B is correct.
The correct answers are B and D.
[ July 19, 2006: Message edited by: Ugender Rekulampally ] [ July 19, 2006: Message edited by: Ugender Rekulampally ]