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

Moderator: admin

Post Reply
ETS User

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

Post by ETS User »

Hi,

Can you please explain why option 1 is not valid?

Thanks!

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

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

Post by admin »

Because rolling back a transaction does not cause the destruction of a session bean. That is as per the specification.

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

Guest

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

Post by Guest »

But In case of a system exception, the transaction is rolled back and the bean is discarded, right?

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

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

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

sanju.ait@gmail.com
Posts: 38
Joined: Fri Aug 16, 2013 11:37 pm
Contact:

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

Post 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.

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

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

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

sanju.ait@gmail.com
Posts: 38
Joined: Fri Aug 16, 2013 11:37 pm
Contact:

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

Post 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.

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

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

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

johnlong
Posts: 197
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

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

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

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

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

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

johnlong
Posts: 197
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

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

Post by johnlong »

Then invoking @Remove(retainIfException=false) method with will always destroy session bean?

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

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

Post by admin »

Yes, that is correct.
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 28 guests