About Question enthuware.oce-jpad.v6.2.406 :

Moderator: admin

Post Reply
piotr.kraciuk
Posts: 9
Joined: Sat May 09, 2015 6:30 am
Contact:

About Question enthuware.oce-jpad.v6.2.406 :

Post by piotr.kraciuk » Wed Jul 29, 2015 9:58 am

"The bean A instance will NOT be discarded." I believe this answer is analogous to the "Changes made to the database by mA(), will be committed." - outcome in those 2 questions might happen, but we cannot be sure they will happen.

The bean A's instance can recover from the exception, but it might also not recover, and thus be discarded. That is why in my opinion this answer should be rephrased to something like "The bean A instance might not be discarded."

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

Re: About Question enthuware.oce-jpad.v6.2.406 :

Post by admin » Thu Jul 30, 2015 11:30 pm

Your point is valid but that is not what the question is about. Bean A will not be not be discarded because of a runtime exception thrown by Bean B. Bean A will be discarded if a runtime exception is thrown out of Bean A but that is not the point in the question. The question is only only talking about the effects of runtime exception thrown by Bean B.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

crolip
Posts: 6
Joined: Mon Jun 16, 2014 9:47 am
Contact:

Re: About Question enthuware.oce-jpad.v6.2.406 :

Post by crolip » Tue Aug 18, 2015 5:48 pm

Well, both cases might only happens because of the runtime exception thrown by Bean B. :)
So, both cases might occur or not.

PtFyEH
Posts: 8
Joined: Sun Dec 20, 2015 6:28 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.406 :

Post by PtFyEH » Tue Sep 06, 2016 11:52 am

Another Question:

What I don't understand: about the exception that is thrown it is only known that it is a RuntimeException. Thus it might be a System Exception as RuntimeExceptions are per default System Exceptions (14.2.2) or it might be an Application Exception if it is annotated with @ApplicationException (as per section 14.2.1).

So if the exception can be either App or System Exception then Bean A might either receive an EJBException (if System Exception in B) or the re-thrown Application Exception (if Application Exception in B) (section 14.3.1, Table 15, method condition: Required and RequiresNew).

So how can this option be correct:
The Bean A will get a javax.ejb.EJBException but it may continue with the same transaction

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

Re: About Question enthuware.oce-jpad.v6.2.406 :

Post by admin » Tue Sep 06, 2016 8:40 pm

You are right. The problem statement should mention that the RTE thrown by mB() is not marked as an application exception.
thank you for your feedback!
Paul.
If you like our products and services, please help us by posting your review here.

tioola
Posts: 6
Joined: Mon Sep 23, 2013 5:19 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.406 :

Post by tioola » Wed Sep 14, 2016 6:28 am

Hello,

I`m a little confused regarding the answer

The Bean A will get a javax.ejb.EJBException but it may continue with the same transaction.

In my understanding when a RuntimeException is throw, the behavior should be

1) roll back the transaction 2) discard the EJB Bean instance 3) Throw a javax.ejb.EJBException

There is no place saying that Bean A is treating (catching) the transaction, if no try catch was defined should Bean A continue the transaction?

Thanks

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

Re: About Question enthuware.oce-jpad.v6.2.406 :

Post by admin » Wed Sep 14, 2016 10:46 am

That is because bean B's transaction attribute is RequiresNew. Therefore, its method executes in a transaction that is different from Bean A's transaction. It cannot affect the transaction of Bean A.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

tioola
Posts: 6
Joined: Mon Sep 23, 2013 5:19 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.406 :

Post by tioola » Thu Sep 15, 2016 5:10 am

Thanks Paul

__JJ__
Posts: 125
Joined: Thu Jul 05, 2018 6:44 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.406 :

Post by __JJ__ » Sun Sep 23, 2018 12:20 pm

Is it the case that bean B would get EJBTransactionRolledbackException, and that this same exception is wrapped into the EJBException that is returned to bean A?

__JJ__
Posts: 125
Joined: Thu Jul 05, 2018 6:44 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.406 :

Post by __JJ__ » Sun Sep 23, 2018 12:32 pm

Also, in looking at table 15 in the EJB spec, they seem only to list the simple case where a client calls a bean; but in the questions in these mock exams the client calls bean A which then calls bean B; is it the case that when (in these questions) "the client" calls bean A and bean A calls bean B, that bean A is a client of bean B (for the purposes of reading table 15), whilst also it being the case that "the client" (as named in the question) is (obviously) the client of bean A?

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

Re: About Question enthuware.oce-jpad.v6.2.406 :

Post by admin » Sun Sep 23, 2018 11:53 pm

Yes, "client" is relative. The caller, even if it is a bean, is the "client" when it invokes another bean.
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 2 guests