Page 1 of 1

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

Posted: Sun May 01, 2011 1:26 pm
by jszczepankiewicz
In the answer (explanation) is "(...)has been designated as a Removemethod(...)",
should be:
"(...)has been designated as a Remove method(...)".

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

Posted: Mon May 02, 2011 6:33 am
by admin
This has been fixed.
Thank you for the feedback!

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

Posted: Mon Jun 06, 2011 6:30 pm
by max2fl
Hi,

from explanations:
An ejb acquires resources in PostCreate (and PostActivate) callback methods and it releases the same resources in PreDestroy (and PrePassivate) methods.
should be:
An ejb acquires resources in PostConstruct (and PostActivate) callback methods and it releases the same resources in PreDestroy (and PrePassivate) methods.

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

Posted: Sun May 13, 2012 6:45 am
by prakashyaji
Hi Paul,

I need one doubt here... Please help me...
"Remember:
An ejb acquires resources in PostConstruct (and PostActivate) callback methods and it releases the same resources in PreDestroy (and PrePassivate) methods.
If a bean is passivated and if the timeout occurs, the container does not call the PreDestroy method."

Here, I remember reading somewhere that, if SystemException occurs then also PreDestroy method is not invoked. In such scenarios we have to do cleanup in lifecycle event callback interceptors. Am I correct? Please clarify.

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

Posted: Sun May 13, 2012 5:31 pm
by admin
prakashyaji wrote:Hi Paul,

I need one doubt here... Please help me...
"Remember:
An ejb acquires resources in PostConstruct (and PostActivate) callback methods and it releases the same resources in PreDestroy (and PrePassivate) methods.
If a bean is passivated and if the timeout occurs, the container does not call the PreDestroy method."

Here, I remember reading somewhere that, if SystemException occurs then also PreDestroy method is not invoked. In such scenarios we have to do cleanup in lifecycle event callback interceptors. Am I correct? Please clarify.
PreDestroy is a life cycle call back listener method and it is not called in case of system exception.
As per Section 4.6.3 of EJB 3.1 specification:
The application using the session bean should provide some clean up mechanism to periodically clean up the unreleased resources.
For example, if a shopping cart component is implemented as a session bean, and the session bean stores the shopping cart content in a database, the application should provide a program that runs periodically and removes “abandoned” shopping carts from the database.
HTH,
Paul.

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

Posted: Thu Feb 07, 2019 1:08 pm
by henrid
I once read in a book that every stateful session bean should have at least one method with @Remove. But I cannot find it in the spec, so can anyone confirm that my statement is true or false?

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

Posted: Fri Feb 08, 2019 1:07 am
by admin
As per section 4.3.11:
A stateful session bean written to the EJB 3.x API typically has one or more remove methods designated by means of the Remove annotation or remove-method deployment descriptor element.
So, it is not mandatory but used commonly so that the bean can do any cleanup while being removed.

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

Posted: Fri Feb 08, 2019 1:38 pm
by henrid
Good to know, thanks!