Page 1 of 1

Re: About Question enthuware.oce-ejbd.v6.2.526 :

Posted: Thu Jun 30, 2011 9:21 am
by vhalitsyn
"Since mA() encounters a system exception (thrown by mB()), it will translate to EJBException for the client. However, the client's transaction will not be rolled back because of the above mentioned reason."
But
"since mB() executes within mA()'s transaction context, the container will mark it for rollback and throw javax.ejb.EJBTransactionRolledbackException to mA() when mB() encounters a system exception."
So mA() gets the EJBTransactionRolledbackException which is not handled. How come does it translate to EJBException?
Although the answer is correct the explanation is not fully, or I missed smth :)

Re: About Question enthuware.oce-ejbd.v6.2.526 :

Posted: Thu Jun 30, 2011 1:54 pm
by admin
This is as per Table 15 Section 14.3.1 of EJB 3.1 Specification.

Method Condition
If the bean method runs in the context of a transaction that the container started immediately before dispatching the business method. This case may happen with Required and RequiresNew attributes.

Method Exception
all other exceptions

Container's Action
Log the exception or error.
Rollback the container-started transaction.
Discard instance.
Throw EJBException to client.[Note E]

Client's View
Receives EJBException.
If the client executes in a transaction, the client’s transaction may or may not be marked for rollback.

Re: About Question enthuware.oce-ejbd.v6.2.526 :

Posted: Thu Jun 27, 2013 9:36 am
by Lommelygte
You argue that the 6th answer is incorrect because a bean will be discarded when it receives a system exception.
But the client receives an EJBException, so by following the previous argument, the client should be discarded as well.
So why is A discarded, but not the client? They both receive a system exception.

Re: About Question enthuware.oce-ejbd.v6.2.526 :

Posted: Thu Jun 27, 2013 3:48 pm
by admin
As mentioned in the explanation of the first option, "The client has an option to catch the EJBException and continue with its transaction."

The bean is discarded only when it doesn't handle a system exception.

HTH,
Paul.

Re: About Question enthuware.oce-ejbd.v6.2.526 :

Posted: Tue Nov 18, 2014 4:40 am
by prekezes
mB() runs in the context of transaction created by the call to mA(). So I don't get why you interpret the "Method condition" ( refering to Table 15 Section 14.3.1 of EJB 3.1 Specification) as:
"Bean method runs in the context of a transaction that the container started immediately before dispatching the business method.
This case may happen with Required and RequiresNew attributes."

And not as:
"Bean method runs in the context of the caller’s transaction [Note A].
This case may happen with Required, Mandatory, and Supports attributes"

which I think is our case? (BeanB with SUPPORTS attribute)

Re: About Question enthuware.oce-ejbd.v6.2.526 :

Posted: Tue Nov 18, 2014 9:21 am
by admin
The reference to table 15 in my post above is for the case with Client to Bean A (which has RequiresNew) not for Bean A to Bean B.

HTH,
Paul.

Re: About Question enthuware.oce-ejbd.v6.2.526 :

Posted: Sun Dec 28, 2014 8:42 am
by ramy6_1
Hello ,

In the sixth option "The bean A instance will NOT be discarded."

You explained "It will receive a javax.ejb.EJBTransactionRolledbackException .............. Therefore, the bean instance will be discarded."

So please explain , the bean A instance will be discarded or not ??!
In both cases you may need to fix the description / question.

Kindly explain

Re: About Question enthuware.oce-ejbd.v6.2.526 :

Posted: Sun Dec 28, 2014 9:37 am
by admin
Not sure what is the issue. This is a wrong option and the explanation explains why it is wrong (because it will be discarded).

HTH,
Paul.

Re: About Question enthuware.oce-ejbd.v6.2.526 :

Posted: Tue Mar 21, 2017 4:02 am
by selvehed
"All invocations are local, involve non-singleton beans, and do not contain try/Catch for RuntimeExceptions"
How come the client that gets the EJBException, but doesn't Catch it according to the question, can continue with the same transaction?
It doesn't Catch it so the client bean instance should be discarded and it's transaction rolled back!
Why isn't the first option correct?

Re: About Question enthuware.oce-ejbd.v6.2.526 :

Posted: Tue Mar 21, 2017 4:31 am
by admin
You are right. I have updated the option to, "The client's transaction will be marked for roll back and cannot be recovered even if it catches the exception received upon calling mA()."

thank you for your feedback!
Paul.

Re: About Question enthuware.oce-ejbd.v6.2.526 :

Posted: Tue Mar 21, 2017 4:52 am
by selvehed
I'm not sure I agree with that new option. If it catches the EJBException it should be able to recover since it has it's own transaction.
But I am the student here and might of course be wrong =)

Re: About Question enthuware.oce-ejbd.v6.2.526 :

Posted: Tue Mar 21, 2017 5:01 am
by admin
Right, and that is why it is not a correct option.