Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple applications having c3p0 configuration gives warning

Tags:

hibernate

c3p0

Hi
I have two web application under one tomcat. Both are using hibernate 3.2.1 and c3p0 0.9.1.2. While the second application gets deployed, I always get the following warning message.
Tomcat: apache-tomcat-6.0.28

WARN 2010-11-06 19:04:37,270 A C3P0Registry mbean is already registered. This probably means that an application using c3p0 was undeployed, but not all PooledDataSources were closed prior to undeployment. This may lead to resource leaks over time. Please take care to close all PooledDataSources.

Please help in this regard.

Thanks in advance
Goura

like image 821
Goura Avatar asked Nov 06 '10 15:11

Goura


People also ask

How does c3p0 work?

c3p0 is a Java library that provides a convenient way for managing database connections. In short, it achieves this by creating a pool of connections. It also effectively handles the cleanup of Statements and ResultSets after use.

What is c3p0 Hibernate connection pooling?

C3p0 is an open-source JDBC connection pooling library, with support for caching and reuse of PreparedStatements. Hibernate provides support for Java applications to use c3p0 for connection pooling with additional configuration settings.

What is maxConnectionAge?

maxConnectionAge & maxIdleTime : maxConnectionAge is the absolute age in seconds of a connection before the pool purges it while the maxIdleTime is the time in seconds a connection can remain pooled but unused before being discarded.


2 Answers

To avoid the C3P0Registry from being loaded and registered multiple times (when deploying multiple webapps, when reloading a given webapp), my recommendation would be to move the C3P0 JAR (and the JDBC driver) from the Webapp classloader (WebappX/WEB-INF/lib) to the Common classloader ($TOMCAT_HOME/lib).

like image 97
Pascal Thivent Avatar answered Feb 23 '23 04:02

Pascal Thivent


If you dont want c3p0 exposed through JMX then you could do:

com.mchange.v2.c3p0.management.ManagementCoordinator=com.mchange.v2.c3p0.management.NullManagementCoordinator
like image 28
cherouvim Avatar answered Feb 23 '23 05:02

cherouvim