File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes sample Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "sample Question" Watch "sample Question" New topic

sample Question

Balaji Anand
Ranch Hand

Joined: Nov 03, 2004
Posts: 146

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?
Sandeep Prabhakar
Ranch Hand

Joined: Dec 22, 2005
Posts: 59
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.

Please correct me if I am wrong.

Ugender Rekulampally
Ranch Hand

Joined: Nov 14, 2005
Posts: 135
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)

Hope this time this is clearer.

[ June 28, 2006: Message edited by: Ugender Rekulampally ]
Consider Paul's rocket mass heater.
subject: sample Question
It's not a secret anymore!