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

Moderator: admin

Post Reply
vhalitsyn

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

Post by vhalitsyn » Thu Jun 30, 2011 9:21 am

"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 :)

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

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

Post by admin » Thu Jun 30, 2011 1:54 pm

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

Lommelygte
Posts: 2
Joined: Thu Jun 27, 2013 9:32 am
Contact:

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

Post by Lommelygte » Thu Jun 27, 2013 9:36 am

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.

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

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

Post by admin » Thu Jun 27, 2013 3:48 pm

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

prekezes
Posts: 1
Joined: Thu Nov 06, 2014 3:00 am
Contact:

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

Post by prekezes » Tue Nov 18, 2014 4:40 am

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)

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

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

Post by admin » Tue Nov 18, 2014 9:21 am

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

ramy6_1
Posts: 124
Joined: Wed Feb 12, 2014 2:44 am
Contact:

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

Post by ramy6_1 » Sun Dec 28, 2014 8:42 am

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

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

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

Post by admin » Sun Dec 28, 2014 9:37 am

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

selvehed
Posts: 9
Joined: Wed Feb 22, 2017 4:32 am
Contact:

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

Post by selvehed » Tue Mar 21, 2017 4:02 am

"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?

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

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

Post by admin » Tue Mar 21, 2017 4:31 am

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

selvehed
Posts: 9
Joined: Wed Feb 22, 2017 4:32 am
Contact:

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

Post by selvehed » Tue Mar 21, 2017 4:52 am

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 =)

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

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

Post by admin » Tue Mar 21, 2017 5:01 am

Right, and that is why it is not a correct option.
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 3 guests