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 3 correct options.
1) The client's transaction will be marked for roll back. 2) The client will get a javax.ejb.EJBException but it can continue with the same transaction. 3) The client will get a javax.ejb.TransactionRolledbackLocalException 4) The bean B instance will be discarded. 5) mA() will get a javax.ejb.TransactionRolledbackLocalException 6) The bean A instance will NOT be discarded. 7) Changes made to the database by mA(), will be commited.
The correct answers marked was 2,4,5. but i disagree with 2 being correct. the spec only states that the client tran may or may not be marked for rollback.
Has this kind of questions appeared on the real exam?
Hey, The option "The client will get a javax.ejb.EJBException but it can continue with the same transaction" does not mean that the client transaction is rolledback. I feel that it's a way of informing the client that something bad has happened during the execution of method A. Now it's upto the client to decide if it should continue the transaction it owns or not.
Srividhya, I think we discussed this question before. choice 2 confuses some times..
see, Client running/calling his methods may be in a transaction or not in a transaction and calls methods on Bean A which starts a new transaction which is TxA and you get exception in that transaction. So you just inform back the client that some thing went wrong in TxA and its upto the client to decide to roll back his transaction or not.
Client(TxC or no transaction) ------> Bean A (TxA) ------> Bean B (TxA)