Page 1 of 1

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

Posted: Sat Jan 19, 2013 1:17 pm
by ETS User
Hi,

Can you please explain why option 1 is not valid?

Thanks!

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

Posted: Sat Jan 19, 2013 3:23 pm
by admin
Because rolling back a transaction does not cause the destruction of a session bean. That is as per the specification.

HTH,
Paul.

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

Posted: Sun Jan 20, 2013 4:36 am
by Guest
But In case of a system exception, the transaction is rolled back and the bean is discarded, right?

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

Posted: Sun Jan 20, 2013 7:50 am
by admin
Yes, so the reason for destruction is the system exception, not the rollback of the transaction. Therefore, it cannot be said that if you rollback the transaction, the bean will be destroyed.

HTH,
Paul.

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

Posted: Mon Aug 26, 2013 11:50 am
by sanju.ait@gmail.com
"when a bean method throws a non-application exception." is also wrong I guess.

Reason : When method throes checked non application exceptions like IOException, bean won't be destroyed.

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

Posted: Mon Aug 26, 2013 3:13 pm
by admin
sanju.ait@gmail.com wrote:"when a bean method throws a non-application exception." is also wrong I guess.

Reason : When method throes checked non application exceptions like IOException, bean won't be destroyed.
Can you please specify where did you see that because I don't see that in the specification.

-Paul.

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

Posted: Tue Aug 27, 2013 11:57 am
by sanju.ait@gmail.com
As mentioned by you, @ApplicationException is not required for an exception to be an application exception if the exception is a checked exception.

So applying that logic here, IOException won't destroy the bean.

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

Posted: Tue Aug 27, 2013 12:52 pm
by admin
sanju.ait@gmail.com wrote:As mentioned by you, @ApplicationException is not required for an exception to be an application exception if the exception is a checked exception.

So applying that logic here, IOException won't destroy the bean.
I am sorry but have no idea what you are trying to say. Where is IOException coming into picture in this question.

You wrote,
"when a bean method throws a non-application exception." is also wrong I guess.
And I explained to you that your argument is not correct. A bean is destroyed when a non-application exception is thrown. That is why option 2 is correct.

IOException is an Application Exception, so the bean will not be destroyed. But the option that you are talking about is saying something else.

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

Posted: Sun Jun 11, 2017 9:34 am
by johnlong
If @Remove(retainIfException=false) is used, the bean is destroyed even if the @Remove method throws an exception.
I have two questions about this situation.
First, If remove method throws exception an as in described above, @PreDestroy won't be called, correct?
Second, can we say that invoking @Remove method will always destroy session bean?

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

Posted: Sun Jun 11, 2017 9:33 pm
by admin
1. No, if the bean is removed then @PreDestroy will be called. The rule is if the @Remove annotation specifies the value of retainIfException as true, and the Remove method throws an application exception, the instance is not removed and the PreDestroy lifecycle callback interceptor methods are not invoked.

2. No, as mentioned above, it will not be removed if @PreDestroy throws an application exception and retainIfException is true.

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

Posted: Mon Jun 12, 2017 9:08 am
by johnlong
Then invoking @Remove(retainIfException=false) method with will always destroy session bean?

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

Posted: Mon Jun 12, 2017 9:27 pm
by admin
Yes, that is correct.