You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by wild_oscar <mi...@almeida.at> on 2007/09/07 19:49:41 UTC
Closing Hibernate's SessionFactory when undeploying (or when is a
filter destroyed)
I've implemented a struts 2 interceptor to create hibernate's SessionFactory
and manage sessions. My session factory is wrapped in a static class:
public static SessionFactory factory;
static {
try {
Configuration cf = new Configuration();
factory = cf.configure().buildSessionFactory();
} catch (Throwable ex) {
throw new ExceptionInInitializerError(ex);
}
}
The problem is that every time I undeploy or redeploy my application,
connections to the database persist because I don't call the
sessionfactory.close() method.
How can I call this method right before tomcat undeploys the application?
--
View this message in context: http://www.nabble.com/Closing-Hibernate%27s-SessionFactory-when-undeploying-%28or-when-is-a-filter-destroyed%29-tf4402912.html#a12560350
Sent from the Tomcat - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: Closing Hibernate's SessionFactory when undeploying (or when is afilter destroyed)
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: wild_oscar [mailto:miguel@almeida.at]
> Subject: Closing Hibernate's SessionFactory when undeploying
> (or when is afilter destroyed)
>
> How can I call this method right before tomcat undeploys the
> application?
Try implementing a ServletContextListener; see section 10 of the servlet
spec for details.
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org