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

Moderator: admin

Post Reply
ETS User

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

Post 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

admin
Site Admin
Posts: 10064
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 72 guests