-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Tomcat Cluster + FarmWarDeployer + Hibernate = issues
PostPosted: Wed Sep 25, 2013 7:53 am 
Newbie

Joined: Tue Sep 24, 2013 4:25 pm
Posts: 2
We have a web application that uses Hibernate. Here is what is in the WEB-INF/lib directory:
(I am not the developer).

hibernate3.jar
hibernate-c3p0-4.1.1.Final.jar
hibernate-commons-annotations-4.0.2.Final.jar
hibernate-core-4.2.2.Final.jar
hibernate-entitymanager-4.2.2.Final.jar
hibernate-jpa-2.0-api-1.0.1.Final.jar
hibernate-tools-4.0.0-CR1.jar

We have a clustered Tomcat7 (apache + mod_jk) environment and are attempting to use the FarmWarDeployer. The FarmWarDeployer is working - it deploys the war across the farm.

The Problem
The problem we are having is that the connections to the MySQL servers are not being closed when the FarmWarDeployer re-deploys the WAR. The connections to the MySQL server remain and when the application restarts it doesn't use the same MySQL connections and it doesn't create new connections. The application faults saying it cannot connect to the database server (see log below). We have to restart Tomcat in order to get the application to work properly.

catalina.out
Code:
=====================Intialize session====================
....
Sep 24, 2013 1:47:50 PM org.apache.catalina.ha.deploy.FarmWarDeployer fileModified
INFO: Installing webapp [/WebTools] from [/d01/tomcat/wt/test/eci/webapps/WebTools.war]
Sep 24, 2013 1:47:50 PM org.apache.catalina.ha.deploy.FarmWarDeployer remove
INFO: Cluster wide remove of web app [/WebTools]
Sep 24, 2013 1:47:50 PM org.apache.catalina.startup.HostConfig checkResources
INFO: Undeploying context [/WebTools]
Sep 24, 2013 1:47:51 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/WebTools] appears to have started a thread named [C3P0PooledConnectionPoolManager[identityToken->1br4n4i8xmhgjgp1p43mhh|5e648d63]-AdminTaskTimer] but has failed to stop it. This is very likely to create a memory leak.
Sep 24, 2013 1:47:51 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/WebTools] appears to have started a thread named [C3P0PooledConnectionPoolManager[identityToken->1br4n4i8xmhgjgp1p43mhh|5e648d63]-HelperThread-#0] but has failed to stop it. This is very likely to create a memory leak.
Sep 24, 2013 1:47:51 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/WebTools] appears to have started a thread named [C3P0PooledConnectionPoolManager[identityToken->1br4n4i8xmhgjgp1p43mhh|5e648d63]-HelperThread-#1] but has failed to stop it. This is very likely to create a memory leak.
Sep 24, 2013 1:47:51 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/WebTools] appears to have started a thread named [C3P0PooledConnectionPoolManager[identityToken->1br4n4i8xmhgjgp1p43mhh|5e648d63]-HelperThread-#2] but has failed to stop it. This is very likely to create a memory leak.
Sep 24, 2013 1:47:51 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/WebTools] appears to have started a thread named [C3P0PooledConnectionPoolManager[identityToken->1br4n4i8xmhgjgp1p43mhh|b9b91c6]-AdminTaskTimer] but has failed to stop it. This is very likely to create a memory leak.
Sep 24, 2013 1:47:51 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/WebTools] appears to have started a thread named [C3P0PooledConnectionPoolManager[identityToken->1br4n4i8xmhgjgp1p43mhh|b9b91c6]-HelperThread-#0] but has failed to stop it. This is very likely to create a memory leak.
Sep 24, 2013 1:47:51 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/WebTools] appears to have started a thread named [C3P0PooledConnectionPoolManager[identityToken->1br4n4i8xmhgjgp1p43mhh|b9b91c6]-HelperThread-#1] but has failed to stop it. This is very likely to create a memory leak.
Sep 24, 2013 1:47:51 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /d01/tomcat/wt/test/eci/webapps/WebTools.war
Sep 24, 2013 1:47:51 PM org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor report
INFO: ThroughputInterceptor Report[
  Tx Msg:20025 messages
  Sent:204.81 MB (total)
  Sent:204.82 MB (application)
  Time:4.94 seconds
  Tx Speed:41.44 MB/sec (total)
  TxSpeed:41.44 MB/sec (application)
  Error Msg:0
  Rx Msg:2 messages
  Rx Speed:0.00 MB/sec (since 1st msg)
  Received:0.00 MB]

Sep 24, 2013 1:47:52 PM org.apache.catalina.loader.WebappClassLoader validateJarFile

=====================Intialize session====================
org.hibernate.exception.GenericJDBCException: Could not open connection
....
Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database!
....
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
....
INSDIE CATCH ERROR Throwable1
org.hibernate.exception.GenericJDBCException: Could not open connection
INSDIE CATCH ERROR Throwable ENDCXV
....
Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database!
....


I'll answer some typical questions:
1) NO, the MySQL server is not out of connections.
2) NO, the user being uses is not out of connections (user is unlimited).
3) Do the stale connections drop? Yes, after the inactivity of 28800 seconds (8 hours).
4) Does the application ever re-establish connection? No. TOMCAT must be restarted.

Anyone have any advice or settings that I need to check or set?
Is there something I should pass on to the developers?


Top
 Profile  
 
 Post subject: Re: Tomcat Cluster + FarmWarDeployer + Hibernate = issues
PostPosted: Thu Sep 26, 2013 7:47 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
hibernate3.jar is likely very old compared to the other ones, containing duplicate and incompatible classes.
Also for the other dependencies, make sure they are aligned (hibernate-c3p0 needs to be the same version as all other hibernate jars).

The error seems unrelated though. MySQL connections need to be monitored actively; last time I've used c3p0 it had some limited capabilities in that sense but that's a long time ago, it might have improved.
For sure you have to configure it to enable health-checks of the connections: it's not automagic, at least it's not in Tomcat where you have to setup all these details yourself.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Tomcat Cluster + FarmWarDeployer + Hibernate = issues
PostPosted: Thu Sep 26, 2013 12:16 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 18, 2012 5:03 am
Posts: 36
Location: Fort Wayne, Indiana, USA
+1 on removing hibernate3.jar and re-aligning everything else -- there will definitely be inconsistencies.

Out of curiosity, can you post your c3p0 config values? Sanne's right that typically something like the following is necessary to actively check MySQL:

Code:
<property name="hibernate.c3p0.validate">true</property>
<property name="hibernate.c3p0.preferredTestQuery">select 1;</property>


Top
 Profile  
 
 Post subject: Re: Tomcat Cluster + FarmWarDeployer + Hibernate = issues
PostPosted: Thu Sep 26, 2013 2:55 pm 
Newbie

Joined: Tue Sep 24, 2013 4:25 pm
Posts: 2
Thank you all for the assistance. I will inform the devs about re-aligning the hibernate files.

We do NOT have any c3p0 properties defined in any property files we are aware off.
Where should they go? In the hibernate.properties file?
What properties should be considered for a clustered environement?


Top
 Profile  
 
 Post subject: Re: Tomcat Cluster + FarmWarDeployer + Hibernate = issues
PostPosted: Thu Oct 03, 2013 1:44 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 18, 2012 5:03 am
Posts: 36
Location: Fort Wayne, Indiana, USA
As a starting point, read through http://docs.jboss.org/hibernate/orm/4.2/manual/en-US/html/ch03.html#configuration-hibernatejdbc

Without c3p0 properties set, Hibernate will use its own rudimentary connection pooling.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.