Page 1 of 1

About Question com.enthuware.ets.scbcd.v5.2.135 :

Posted: Wed Sep 14, 2011 10:58 am
by ETS User
Hi,
Here is the question:
Given the following method code in Bean2 -

public void do2(int x){
if(x == 0) throw new EJBException("not acceptable");
}

This method is called from method do1() of Bean1. Assuming that both the beans are stateless session beans and have transaction attribute of REQUIRED, which of the following statements are correct?


Answers which are correct according to question bank are:
Bean1 will receive EJBTransactionRolledbackException and Bean2 instance will be discarded.
The transaction will be rollbacked.

I'm wondering why this answer is not correct:
Bean1 will receive EJBException and Bean2 instance will be discarded.
If the code explicitly declares that it throws EJBException why the above mentioned answer is not correct? Does EJBTransactionRolledBackException somehow wrap the EJBException.
Thanks in advance for clarifying it for me :)
Regards,
Piotrek

Re: About Question com.enthuware.ets.scbcd.v5.2.135 :

Posted: Thu Sep 15, 2011 7:36 am
by admin
Hello,
Yes, this is as per Table 14 Section 14.3.1 on EJB 3.0 Core specification. Since EJBException is a system exception, the client i.e. bean1 will receive javax.ejb.EJBTransactionRolledbackException

HTH,
Paul.