while handling large Db transaction I encountered the following problem :
java.lang.IllegalStateException: Pool not open at org.apache.commons.pool.BaseObjectPool.assertOpen(BaseObjectPool.java:78) at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:722) at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:95) at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540) at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:81) at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423) at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144) at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:119) at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57) at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326) at com.indictranstech.mbmc.common.utils.AuditTrailHibernateListener.onPostInsert(AuditTrailHibernateListener.java:133) at org.hibernate.action.EntityInsertAction.postInsert(EntityInsertAction.java:131) at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:110) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000) at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338) at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106) at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:656) at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754) at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723) at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:375) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at $Proxy53.merge(Unknown Source)
DB connection is managed by HibernateTemplate. while transaction is managed by Spring Transaction Management. database is PostgreSQL.
The same code works fine when there are 5 to 10 transactions.
Did you use code like this in your project?
Session session = hibernateTemplate.getSessionFactory().openSession();
when you use openSession(),spring will not close it automatically,you shoud use it like this
HttpSession session = null;
session = hibernateTemplate.getSessionFactory().getCurrentSession();
if(null == session) {
session = hibernateTemplate.getSessionFactory().openSession();
}
you can also use hibernate.executeFind(new HibernateCallback(){ ... }) to avoid this problem