Page 1 of 1

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

Posted: Wed Jul 29, 2015 9:58 am
by piotr.kraciuk
"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."

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

Posted: Thu Jul 30, 2015 11:30 pm
by admin
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.

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

Posted: Tue Aug 18, 2015 5:48 pm
by crolip
Well, both cases might only happens because of the runtime exception thrown by Bean B. :)
So, both cases might occur or not.

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

Posted: Tue Sep 06, 2016 11:52 am
by PtFyEH
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

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

Posted: Tue Sep 06, 2016 8:40 pm
by admin
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.

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

Posted: Wed Sep 14, 2016 6:28 am
by tioola
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

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

Posted: Wed Sep 14, 2016 10:46 am
by admin
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.

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

Posted: Thu Sep 15, 2016 5:10 am
by tioola
Thanks Paul

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

Posted: Sun Sep 23, 2018 12:20 pm
by __JJ__
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?

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

Posted: Sun Sep 23, 2018 12:32 pm
by __JJ__
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?

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

Posted: Sun Sep 23, 2018 11:53 pm
by admin
Yes, "client" is relative. The caller, even if it is a bean, is the "client" when it invokes another bean.