Hello, everyone.
I am building a web application that runs in a tomcat container using servlets which use hibernate and c3p0 as a back end.
The vital stats:
Java: 1.6.0_07-b06
Implementation-Title: Hibernate3
Implementation-Version: 3.2.4.sp1
Implementation-Vendor: hibernate.org
Hibernate-Version: 3.2.4.sp1
C3P0 :
Specification-Version: 1.0
Implementation-Vendor-Id: com.mchange
Implementation-Vendor: Machinery For Change, Inc.
Implementation-Version: 0.9.1
=========
I have two questions.
1) I cannot undeploy or reload more than 7 times before I get a perm gen error. This only occurs if I access hibernate, so I know the error is in that portion of the code.
Specifically, my log has the error
SEVERE: A web application registered the JBDC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
May 26, 2011 4:23:07 PM org.apache.catalina.loader.WebappClassLoader clearReferencesStopTimerThread
SEVERE: A web application appears to have started a TimerThread named [Timer-4] via the java.util.Timer API but has failed to stop it. To prevent a memory leak, the timer (and hence the associated thread) has been forcibly cancelled.
May 26, 2011 4:23:07 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: A web application appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] but has failed to stop it. This is very likely to create a memory leak.
May 26, 2011 4:23:07 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: A web application appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] but has failed to stop it. This is very likely to create a memory leak.
May 26, 2011 4:23:07 PM org.apache.catalina.startup.HostConfig checkResources
I assume this means that the C3P0 helper threads have not shut down cleanly.
What am I doing wrong? I added the following code to the appropriate servlet:
Code:
public void destroy() {
HibernateUtil.getSessionFactory().close();
super.destroy();
}
Overriding the servlet's native destroy method should ensure hibernate shuts down when the servlet is unloaded or redeployed. But it doesn't seem to be happening. How do I ensure a clean shutdown?
2) Can anyone point me to some reference material -- books, online links, other -- that will assist me in tuning the hibernate and c3p0 settings in hibernate.cfg.xml? There is the reference manual, of course. I am looking for something that is more involved than a mere tutorial but less comprehensive than the full manual.
This is for an internal system , so it will have very few users. My major concern is to ensure the system will not crash due to a memory leak or some other trivial error that can be easily avoided by getting the settings right.
Respectfully,
Brian P.