[
https://hibernate.onjira.com/browse/HHH-6891?page=com.atlassian.jira.plug...
]
Joseph Carneiro commented on HHH-6891:
--------------------------------------
I'm experiencing a similar issue.
Environment:
Spring 3.1.1
Web Flow 2.3.0
Hibernate 4.1.0
c3p0 0.9.1.2
Problem:
When I make any calls to the EntityManager in a Spring Web Flow the connections are never
closed. I've turned on c3p0 logging and it shows that the pool grows every time I
start a flow. This is a real problem as the pool is exhausted and the application hangs.
Reaching the end-state doesn't release the connections. I have service calls within
the flow that use the EntityManager and c3p0's debug traces indicate these are the
culprits. I've tried calling close on the EntityManager after completing the queries,
but this has no effect. I have several standard Spring Controllers in my application as
well; they make use of the EntityManager through the same service calls and the
connections are closed. Only the flows are keeping the connections open. I'm using
<persistence-context/> in the flows and my EntityManager is annotated with
@PersistenceContext.
Hibernate is not reusing connections from the pool
--------------------------------------------------
Key: HHH-6891
URL:
https://hibernate.onjira.com/browse/HHH-6891
Project: Hibernate ORM
Issue Type: Bug
Components: core
Affects Versions: 4.0.0.CR7
Environment: Hibernate 4, MySQL 5.6
Reporter: Mat Banik
Labels: c3p0, dbcp, hibernate
I have tried two connection pool providers C3P0 and Commons DBCP. Both are the most
current versions.
Everything starts fine. And data is loading from database as expected.
But with C3P0 when left to defaults everything stops when maximum of 15 connections are
reached. Nothing is freed up and the application behaves like it has memory leak.
Here is bottom of log output
2011-12-13/17:21:55.167/EST [http-bio-80-exec-2] DEBUG begin
2011-12-13/17:21:55.167/EST [http-bio-80-exec-2] DEBUG Obtaining JDBC connection
2011-12-13/17:21:55.167/EST [http-bio-80-exec-2] DEBUG acquire test -- pool is already
maxed out. [managed: 15; max: 15]
2011-12-13/17:21:55.167/EST [http-bio-80-exec-2] DEBUG awaitAvailable():
com.mchange.v2.c3p0.impl.NewPooledConnection@46f0decc
2011-12-13/17:21:55.167/EST [http-bio-80-exec-2] DEBUG trace
com.mchange.v2.resourcepool.BasicResourcePool@9671641 [managed: 15, unused: 0, excluded:
0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@46f0decc)
With Commons DBCP everything work as well until when maximum connections are reached and
than it throws exception:
org.springframework.orm.hibernate4.HibernateJdbcException: JDBC exception on Hibernate
data access: SQLException for SQL [n/a]; SQL state [null]; error code [0]; Could not open
connection; nested exception is org.hibernate.exception.GenericJDBCException: Could not
open connection
org.springframework.orm.hibernate4.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:165)
org.springframework.orm.hibernate4.HibernateExceptionTranslator.convertHibernateAccessException(HibernateExceptionTranslator.java:50)
org.springframework.orm.hibernate4.HibernateExceptionTranslator.translateExceptionIfPossible(HibernateExceptionTranslator.java:37)
org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:58)
org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:163)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira