File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes EJB 3.x passivation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "EJB 3.x passivation" Watch "EJB 3.x passivation" New topic

EJB 3.x passivation

pyush singh

Joined: Aug 02, 2013
Posts: 1

In EJB 3.x during passivation does the connection object gets committed when released just before serialization?
Jarek Wa

Joined: Jan 12, 2012
Posts: 6
You should use @PrePassivate and PostActivate callback to properly manage resources used by a bean. Note that for example if Stateful bean times out during passivation, its resources remain open (if not released in PrePassivate).

Spec 4.3.4:

The PrePassivate callback notification signals the intent of the container to passivate the instance. The PostActivate notification signals the instance it has just been reactivated. Their purpose is to allow stateful session beans to maintain those open resources that need to be closed prior to an instance’s passivation and then reopened during an instance’s activation.

Also 4.6.3 for stateful session bean:

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.

I agree. Here's the link:
subject: EJB 3.x passivation
It's not a secret anymore!