org.quartz.SchedulerException: JobListener 'ScheduledJobListener' threw exception: Could not open Hibernate Session for transaction; nested exception is net.sf.hibernate.exception.GenericJDBCException: Cannot open connection [See nested exception: org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is net.sf.hibernate.exception.GenericJDBCException: Cannot open connection]

Atlassian JIRA | Olli Nevalainen [OOO until 6 Oct] | 1 year ago
  1. 0

    Database request is performed before each schedule job is run. If this request fails for any reason (e.g. connection timeout, not enough DB connections in the pool, table missing in DB), the scheduled job will be prevented from running until the instance is restarted. This is the relevant stack trace: {noformat} org.quartz.SchedulerException: JobListener 'ScheduledJobListener' threw exception: Could not open Hibernate Session for transaction; nested exception is net.sf.hibernate.exception.GenericJDBCException: Cannot open connection [See nested exception: org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is net.sf.hibernate.exception.GenericJDBCException: Cannot open connection] at org.quartz.core.QuartzScheduler.notifyJobListenersToBeExecuted(QuartzScheduler.java:1951) at org.quartz.core.JobRunShell.notifyListenersBeginning(JobRunShell.java:364) at org.quartz.core.JobRunShell.run(JobRunShell.java:190) at com.atlassian.confluence.schedule.quartz.ConfluenceQuartzThreadPool.lambda$runInThread$187(ConfluenceQuartzThreadPool.java:19) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549) Caused by: org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is net.sf.hibernate.exception.GenericJDBCException: Cannot open connection at org.springframework.orm.hibernate.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:473) at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:374) at sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198) at com.sun.proxy.$Proxy33.getTransaction(Unknown Source) at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:263) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:101) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at com.sun.proxy.$Proxy142.jobToBeExecuted(Unknown Source) at org.quartz.core.QuartzScheduler.notifyJobListenersToBeExecuted(QuartzScheduler.java:1949) ... 4 more Caused by: net.sf.hibernate.exception.GenericJDBCException: Cannot open connection at net.sf.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:80) at net.sf.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:69) at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29) at net.sf.hibernate.impl.BatcherImpl.convert(BatcherImpl.java:328) at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:295) at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3367) at org.springframework.orm.hibernate.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:422) ... 17 more Caused by: java.sql.SQLException: Cannot get a connection, pool error Timeout waiting for idle object at org.apache.tomcat.dbcp.dbcp2.PoolingDataSource.getConnection(PoolingDataSource.java:126) at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:1412) at net.sf.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:59) at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:292) ... 20 more at org.apache.tomcat.dbcp.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:446) at org.apache.tomcat.dbcp.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:360) at org.apache.tomcat.dbcp.dbcp2.PoolingDataSource.getConnection(PoolingDataSource.java:118) ... 23 more {noformat} Two job listeners are called when execution is starting: # {{ExecutingJobsManager}} keeps a list of jobs which are executing # {{ScheduledJobsListener}} saves execution details to database If {{ScheduledJobsListener}} throws an exception, {{ExecutingJobsManager}} will not get notified that the execution got cancelled. Further executions get cancelled because {{AbstractJob#executeInternal(..)}} checks {{ExecutingJobsManager}} to see if similar (but not same) execution is already happening. *Workaround for Confluence 5.8* For users of Confluence 5.8.18, we are providing a [patch file|^confluence-5.8.18-CONF-39825-patch.zip] containing a fix for this issue. Please be aware that this patch has not been fully tested and is applied at your own risk. We strongly recommend that you test the patch on a staging instance of Confluence before applying it to a production instance. Refer to https://confluence.atlassian.com/doc/installing-patched-class-files-166528493.html for details on how to apply the patch. Also, make sure that the MaxWaitMillis is set to 10000 so that the connection pool got sometime to recover.

    Atlassian JIRA | 1 year ago | Olli Nevalainen
    org.quartz.SchedulerException: JobListener 'ScheduledJobListener' threw exception: Could not open Hibernate Session for transaction; nested exception is net.sf.hibernate.exception.GenericJDBCException: Cannot open connection [See nested exception: org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is net.sf.hibernate.exception.GenericJDBCException: Cannot open connection]
  2. 0

    Database request is performed before each schedule job is run. If this request fails for any reason (e.g. connection timeout, not enough DB connections in the pool, table missing in DB), the scheduled job will be prevented from running until the instance is restarted. This is the relevant stack trace: {noformat} org.quartz.SchedulerException: JobListener 'ScheduledJobListener' threw exception: Could not open Hibernate Session for transaction; nested exception is net.sf.hibernate.exception.GenericJDBCException: Cannot open connection [See nested exception: org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is net.sf.hibernate.exception.GenericJDBCException: Cannot open connection] at org.quartz.core.QuartzScheduler.notifyJobListenersToBeExecuted(QuartzScheduler.java:1951) at org.quartz.core.JobRunShell.notifyListenersBeginning(JobRunShell.java:364) at org.quartz.core.JobRunShell.run(JobRunShell.java:190) at com.atlassian.confluence.schedule.quartz.ConfluenceQuartzThreadPool.lambda$runInThread$187(ConfluenceQuartzThreadPool.java:19) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549) Caused by: org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is net.sf.hibernate.exception.GenericJDBCException: Cannot open connection at org.springframework.orm.hibernate.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:473) at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:374) at sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198) at com.sun.proxy.$Proxy33.getTransaction(Unknown Source) at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:263) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:101) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at com.sun.proxy.$Proxy142.jobToBeExecuted(Unknown Source) at org.quartz.core.QuartzScheduler.notifyJobListenersToBeExecuted(QuartzScheduler.java:1949) ... 4 more Caused by: net.sf.hibernate.exception.GenericJDBCException: Cannot open connection at net.sf.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:80) at net.sf.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:69) at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29) at net.sf.hibernate.impl.BatcherImpl.convert(BatcherImpl.java:328) at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:295) at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3367) at org.springframework.orm.hibernate.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:422) ... 17 more Caused by: java.sql.SQLException: Cannot get a connection, pool error Timeout waiting for idle object at org.apache.tomcat.dbcp.dbcp2.PoolingDataSource.getConnection(PoolingDataSource.java:126) at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:1412) at net.sf.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:59) at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:292) ... 20 more at org.apache.tomcat.dbcp.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:446) at org.apache.tomcat.dbcp.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:360) at org.apache.tomcat.dbcp.dbcp2.PoolingDataSource.getConnection(PoolingDataSource.java:118) ... 23 more {noformat} Two job listeners are called when execution is starting: # {{ExecutingJobsManager}} keeps a list of jobs which are executing # {{ScheduledJobsListener}} saves execution details to database If {{ScheduledJobsListener}} throws an exception, {{ExecutingJobsManager}} will not get notified that the execution got cancelled. Further executions get cancelled because {{AbstractJob#executeInternal(..)}} checks {{ExecutingJobsManager}} to see if similar (but not same) execution is already happening. *Workaround for Confluence 5.8* For users of Confluence 5.8.18, we are providing a [patch file|^confluence-5.8.18-CONF-39825-patch.zip] containing a fix for this issue. Please be aware that this patch has not been fully tested and is applied at your own risk. We strongly recommend that you test the patch on a staging instance of Confluence before applying it to a production instance. Refer to https://confluence.atlassian.com/doc/installing-patched-class-files-166528493.html for details on how to apply the patch. Also, make sure that the MaxWaitMillis is set to 10000 so that the connection pool got sometime to recover.

    Atlassian JIRA | 1 year ago | Olli Nevalainen [OOO until 6 Oct]
    org.quartz.SchedulerException: JobListener 'ScheduledJobListener' threw exception: Could not open Hibernate Session for transaction; nested exception is net.sf.hibernate.exception.GenericJDBCException: Cannot open connection [See nested exception: org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is net.sf.hibernate.exception.GenericJDBCException: Cannot open connection]
  3. 0

    Tomcat 8 - java.sql.SQLException: Cannot create JDBC driver of class '' for connect URL 'jdbc:mysql://xxx/myApp'

    Stack Overflow | 2 years ago | Brutus
    java.sql.SQLException: Cannot create JDBC driver of class '' for connect URL 'jdbc:mysql://xxx/myApp' t org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createConnectionFactory(BasicDataSource.java:2065)
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Receiving Data source is Closed error using spring-boot 1.2.7 in Tomcat 8 Java 8

    Stack Overflow | 1 year ago | Daniel Trimble
    org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Data source is closed
  6. 0

    Error on deploying web application on tomcat 8 - No suitable driver

    Stack Overflow | 1 year ago | user3179215
    org.hibernate.exception.GenericJDBCException: Could not open connection

  1. Shadd518 3 times, last 4 months ago
5 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.sql.SQLException

    Cannot get a connection, pool error Timeout waiting for idle object

    at org.apache.tomcat.dbcp.dbcp2.PoolingDataSource.getConnection()
  2. org.apache.tomcat
    BasicDataSource.getConnection
    1. org.apache.tomcat.dbcp.dbcp2.PoolingDataSource.getConnection(PoolingDataSource.java:126)
    2. org.apache.tomcat.dbcp.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:1412)
    2 frames
  3. net.sf.hibernate
    SessionImpl.connection
    1. net.sf.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:59)
    2. net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:292)
    3. net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:295)
    4. net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3367)
    4 frames
  4. Hibernate
    HibernateTransactionManager.doBegin
    1. org.springframework.orm.hibernate.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:422)
    2. org.springframework.orm.hibernate.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:473)
    2 frames
  5. Spring Tx
    AbstractPlatformTransactionManager.getTransaction
    1. org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:374)
    1 frame
  6. Java RT
    Method.invoke
    1. sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source)
    2. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    3. java.lang.reflect.Method.invoke(Method.java:497)
    3 frames
  7. Spring AOP
    JdkDynamicAopProxy.invoke
    1. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
    1 frame
  8. com.sun.proxy
    $Proxy33.getTransaction
    1. com.sun.proxy.$Proxy33.getTransaction(Unknown Source)
    1 frame
  9. Spring Tx
    TransactionInterceptor.invoke
    1. org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:263)
    2. org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:101)
    2 frames
  10. Spring AOP
    JdkDynamicAopProxy.invoke
    1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    2. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    2 frames
  11. com.sun.proxy
    $Proxy142.jobToBeExecuted
    1. com.sun.proxy.$Proxy142.jobToBeExecuted(Unknown Source)
    1 frame
  12. quartz
    JobRunShell.run
    1. org.quartz.core.QuartzScheduler.notifyJobListenersToBeExecuted(QuartzScheduler.java:1949)
    2. org.quartz.core.JobRunShell.notifyListenersBeginning(JobRunShell.java:364)
    3. org.quartz.core.JobRunShell.run(JobRunShell.java:190)
    3 frames
  13. com.atlassian.confluence
    ConfluenceQuartzThreadPool.lambda$runInThread$187
    1. com.atlassian.confluence.schedule.quartz.ConfluenceQuartzThreadPool.lambda$runInThread$187(ConfluenceQuartzThreadPool.java:19)
    1 frame
  14. quartz
    SimpleThreadPool$WorkerThread.run
    1. org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
    1 frame