Reputation: 6650
My c3p0 configuration is as following , and at times I receive the following error messages in my console. Why am I receiving this?
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">100</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
<property name="current_session_context_class">thread</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
Hibernate Configuration
private static SessionFactory sessionFactory = buildSessionFactory();
private static SessionFactory buildSessionFactory() {
try {
System.err.println("in session Facotry");
Configuration configuration = new Configuration();
return configuration.configure().buildSessionFactory(
new StandardServiceRegistryBuilder().applySettings(configuration.getProperties())
.build());
} catch (HibernateException ex) {
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
Error
INFO: WARN - Failed to destroy resource: com.mchange.v2.c3p0.impl.NewPooledConnection@67a781cc
30 Jun 2014 11:57:59java.lang.IllegalStateException: This web container has not yet been started
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1652)
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1611)
at com.mchange.v2.c3p0.stmt.GooGooStatementCache.synchronousDestroyStatement(GooGooStatementCache.java:413)
at com.mchange.v2.c3p0.stmt.GooGooStatementCache.closeAll(GooGooStatementCache.java:351)
at com.mchange.v2.c3p0.impl.NewPooledConnection.closeAllCachedStatements(NewPooledConnection.java:598)
at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:468)
at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:191)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:470)
at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:964)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
Upvotes: 2
Views: 5266
Reputation: 14083
So, this is a ClassLoader issue, likely having to do with a stale pool still running while an application is hot-redeplying. Here are some suggestions:
Make sure that your hibernate SessionFactory is cleanly close()ed in some hook while your application shuts down, e.g. in a SessionContextListener. close()ing the SessionFactory should clean up the pool while the classes it requires are still live. This is the best thing to do, because aside from the messages you are seeing, if you are leaving pools from old app instances alive after your app restarts, you are leaking resources (Threads, Connections).
Upgrade to c3p0-0.9.5-pre8, and try the setting hibernate.c3p0.contextClassLoaderSource
to library
. See http://www.mchange.com/projects/c3p0/#contextClassLoaderSource Be sure to place c3p0's two jar files in an application-server level lib directory, not in a directory subsidiary to a war file or other archive.
Upvotes: 2