java.sql.SQLException: Connection handle has been closed and is unusable

Oracle Community | 3004 | 1 decade ago
  1. 0

    Transaction problem

    Oracle Community | 1 decade ago | 3004
    java.sql.SQLException: Connection handle has been closed and is unusable
  2. 0

    com.br | 11 months ago
    java.sql.SQLException: Connection handle is not currently associated with a ManagedConnection
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    The Quartz job that Artifactory runs to update indexes is consistently throwing an exception due to the fact that the connection is closed and the autoReconnect flag is set to false. [9/11/08 18:06:28:980 PDT] 00000045 SystemOut O 2008-09-11 18:06:28,978 [WARN ] (data.db.DbDataStore :588) - Can not insert new record org.apache.jackrabbit.core.data.DataStoreException: Can not insert new record: connection has been closed and autoReconnect == false: connection has been closed and autoReconnect == false at org.apache.jackrabbit.core.data.db.DbDataStore.convert(DbDataStore.java:592) at org.apache.jackrabbit.core.data.db.DbDataStore.addRecord(DbDataStore.java:295) at org.apache.jackrabbit.core.value.BLOBInDataStore.getInstance(BLOBInDataStore.java:120) at org.apache.jackrabbit.core.value.InternalValue.getBLOBFileValue(InternalValue.java:644) at org.apache.jackrabbit.core.value.InternalValue.create(InternalValue.java:123) at org.apache.jackrabbit.core.PropertyImpl.setValue(PropertyImpl.java:609) at org.apache.jackrabbit.core.PropertyImpl.setValue(PropertyImpl.java:525) at org.apache.jackrabbit.core.NodeImpl.setProperty(NodeImpl.java:2309) at org.artifactory.jcr.fs.JcrFile.fillJcrData(JcrFile.java:591) at org.artifactory.jcr.fs.JcrFile.setResourceNode(JcrFile.java:550) at org.artifactory.jcr.fs.JcrFile.<init>(JcrFile.java:80) at org.artifactory.jcr.fs.JcrFile.<init>(JcrFile.java:164) at org.artifactory.repo.index.RepoIndexerData.saveIndexFiles(RepoIndexerData.java:103) at org.artifactory.repo.index.IndexerManagerImpl.saveIndexFiles(IndexerManagerImpl.java:168) at org.artifactory.repo.index.IndexerManagerImpl$$FastClassByCGLIB$$76058b92.invoke(<generated>) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:700) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:635) at org.artifactory.repo.index.IndexerManagerImpl$$EnhancerByCGLIB$$7cded8f3.saveIndexFiles(<generated>) at org.artifactory.repo.index.IndexerManagerImpl.index(IndexerManagerImpl.java:137) at org.artifactory.repo.index.IndexerManagerImpl$$FastClassByCGLIB$$76058b92.invoke(<generated>) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:700) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:635) at org.artifactory.repo.index.IndexerManagerImpl$$EnhancerByCGLIB$$7cded8f3.index(<generated>) at org.artifactory.repo.index.IndexerJob.onExecute(IndexerJob.java:25) at org.artifactory.schedule.ArtifactoryJob.execute(ArtifactoryJob.java:41) at org.quartz.core.JobRunShell.run(JobRunShell.java:202) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525) Caused by: java.sql.SQLException: connection has been closed and autoReconnect == false at org.apache.jackrabbit.core.persistence.bundle.util.ConnectionRecoveryManager.getConnection(ConnectionRecoveryManager.java:159) at org.apache.jackrabbit.core.persistence.bundle.util.ConnectionRecoveryManager.executeStmtInternal(ConnectionRecoveryManager.java:287) at org.apache.jackrabbit.core.persistence.bundle.util.ConnectionRecoveryManager.executeStmt(ConnectionRecoveryManager.java:257) at org.apache.jackrabbit.core.persistence.bundle.util.ConnectionRecoveryManager.executeStmt(ConnectionRecoveryManager.java:237) at org.apache.jackrabbit.core.data.db.DbDataStore.addRecord(DbDataStore.java:286) ... 33 more The exception is thrown from the ConnectonRecoveryManager here: public synchronized Connection getConnection() throws SQLException, RepositoryException { if (isClosed) { if (autoReconnect) { reestablishConnection(); } else { throw new SQLException("connection has been closed and autoReconnect == false"); } } return connection; } The autoReconnect flag is by default set to true in the ConnectionRecoveryManager (http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ConnectionRecoveryManager.java?view=markup), but the problem is that this is set to false in the DbDataStore.addRecord() method: public DataRecord addRecord(InputStream stream) throws DataStoreException { ResultSet rs = null; TempFileInputStream fileInput = null; ConnectionRecoveryManager conn = getConnection(); try { conn.setAutoReconnect(false); // WHY??? //etc... There is a somewhat simplistic Pool class that holds instances of the ConnectionRecoveryManager (http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/db/Pool.java?view=markup), but it looks like there is no attempt here to test if the connection is still open (a la DBCP) when it is returned from the Pool. This looks like a Jackrabbit bug, but Artifactory probably needs to find a short-term workaround.

    JFrog JIRA | 8 years ago | Brennan Spies
    org.apache.jackrabbit.core.data.DataStoreException: Can not insert new record: connection has been closed and autoReconnect == false: connection has been closed and autoReconnect == false

    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

      Connection handle has been closed and is unusable

      at org.jboss.resource.adapter.jdbc.WrappedConnection.checkStatus()
    2. JBoss Application Server Connector
      WrappedConnection.getWarnings
      1. org.jboss.resource.adapter.jdbc.WrappedConnection.checkStatus(WrappedConnection.java:800)
      2. org.jboss.resource.adapter.jdbc.WrappedConnection.getWarnings(WrappedConnection.java:603)
      2 frames
    3. com.solarmetric.kodo
      EEPersistenceManager.afterCompletion
      1. com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.logWarnings(SQLExecutionManagerImpl.java:1050)
      2. com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.fireEvent(SQLExecutionManagerImpl.java:1030)
      3. com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.close(SQLExecutionManagerImpl.java:899)
      4. com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.end(JDBCStoreManager.java:232)
      5. com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.commit(JDBCStoreManager.java:193)
      6. com.solarmetric.kodo.runtime.PersistenceManagerImpl.endTransaction(PersistenceManagerImpl.java:829)
      7. com.solarmetric.kodo.ee.EEPersistenceManager.afterCompletion(EEPersistenceManager.java:224)
      7 frames
    4. JBoss Transaction 7.1.0 SPI
      TransactionImpl.commit
      1. org.jboss.tm.TransactionImpl.doAfterCompletion(TransactionImpl.java:1331)
      2. org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:410)
      2 frames
    5. JBoss Application Server Server
      Container.invoke
      1. org.jboss.ejb.plugins.TxInterceptorCMT.endTransaction(TxInterceptorCMT.java:369)
      2. org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:253)
      3. org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:104)
      4. org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:117)
      5. org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      6. org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      7. org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:322)
      8. org.jboss.ejb.Container.invoke(Container.java:674)
      8 frames
    6. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:324)
      4 frames
    7. org.jboss.mx
      ReflectedMBeanDispatcher.invoke
      1. org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      1 frame
    8. JBoss Application Server J2SE
      MBeanServerImpl.invoke
      1. org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
      1 frame
    9. JBoss Application Server Server
      JRMPInvoker.invoke
      1. org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:359)
      1 frame
    10. Java RT
      Thread.run
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:324)
      5. sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
      6. sun.rmi.transport.Transport$1.run(Transport.java:148)
      7. java.security.AccessController.doPrivileged(Native Method)
      8. sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      9. sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      10. sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport..java:701)
      11. java.lang.Thread.run(Thread.java:536)
      11 frames