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 » Sat Jan 19, 2013 1:17 pm

Hi,

Can you please explain why option 1 is not valid?

Thanks!

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

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

Post by admin » Sat Jan 19, 2013 3:23 pm

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 » Sun Jan 20, 2013 4:36 am

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

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

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

Post by admin » Sun Jan 20, 2013 7:50 am

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 » Mon Aug 26, 2013 11:50 am

"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: 8239
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin » Mon Aug 26, 2013 3:13 pm

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 » Tue Aug 27, 2013 11:57 am

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: 8239
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin » Tue Aug 27, 2013 12:52 pm

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: 185
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

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

Post by johnlong » Sun Jun 11, 2017 9:34 am

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: 8239
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin » Sun Jun 11, 2017 9:33 pm

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: 185
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

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

Post by johnlong » Mon Jun 12, 2017 9:08 am

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

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

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

Post by admin » Mon Jun 12, 2017 9:27 pm

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 3 guests