9 Replies Latest reply on Aug 10, 2007 4:10 PM by matt zaber

    Connection handle has been closed and is unusable

    Mark Jones Newbie

      Hi. There is a huge amount of noise relating to this error all over the place. I'm not really sure if it is a seam/AS/Hibernate issue.

      The stack is as follows



      Caused by: java.sql.SQLException: Connection handle has been closed and is unusable
       at org.jboss.resource.adapter.jdbc.WrappedConnection.checkStatus(WrappedConnection.java:537)
       at org.jboss.resource.adapter.jdbc.WrappedConnection.checkTransaction(WrappedConnection.java:524)
       at org.jboss.resource.adapter.jdbc.WrappedConnection.prepareStatement(WrappedConnection.java:184)
       at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:497)
       at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:415)
       at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
       at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1560)
       at org.hibernate.loader.Loader.doQuery(Loader.java:661)
       at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
       at org.hibernate.loader.Loader.loadCollection(Loader.java:1918)


      This was occurring frequently and I added

      <valid-connection-checker-class-name>com.mysql.jdbc.integration.jboss.MysqlValidConnectionChecker</valid-connection-checker-class-name>
       <check-valid-connection-sql>SELECT count(warehouseId) FROM warehouse</check-valid-connection-sql>
      which I dont think had an effect (the errors were still common). I upgraded the hibernate versions in Seam 1.2.1 to the latest hibernate which definitely reduced the frequency however they are still there. Any suggestions welcome.


      (Just in case it helps)
      One thing I did notice which admittedly is likely a red herring is that the errors seem to happen where concurrent modification is likely i.e. separate threads modifying the same data. As one thread is only reading ever then I cant see that this could be an issue.