0 Replies Latest reply on May 22, 2006 11:12 AM by jim burton

    intermittent crashes: Connection handle is not currently ass

    jim burton Newbie

      I have a struts/hibernate webapp that throws exceptions intermittently relating to the connection handle, eg:

      2006-05-22 15:04:24,947 DEBUG [org.hibernate.jdbc.JDBCContext] running Session.finalize()
      2006-05-22 15:04:24,947 DEBUG [org.hibernate.jdbc.JDBCContext] running Session.finalize()
      2006-05-22 15:04:25,913 DEBUG [org.hibernate.transaction.JDBCTransaction] begin
      2006-05-22 15:04:25,913 ERROR [org.hibernate.transaction.JDBCTransaction] JDBC begin failed
      java.sql.SQLException: Connection handle is not currently associated with a ManagedConnection
       at org.jboss.resource.adapter.jdbc.WrappedConnection.checkStatus(Wrapped
      Connection.java:528)
       at org.jboss.resource.adapter.jdbc.WrappedConnection.getAutoCommit(Wrapp
      edConnection.java:324)
       at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:
      49)
       at org.hibernate.transaction.JDBCTransactionFactory.beginTransaction(JDBCTransactionFactory.java:19)
       at org.hibernate.jdbc.JDBCContext.beginTransaction(JDBCContext.java:204)
       at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1014)
       at uk.gov.brightonhove.central.dao.UserDao.getUser(Unknown Source)
       at uk.gov.brightonhove.central.users.UserAction.setupEditUser(Unknown So
      

      I understand that this error indicates I'm trying to use a connection after it's been closed but I can't work out why this would be the case. BTW, am I right in thinking

      The code in my DAO classes that uses Hibernate looks like:

      try {
       Session session = HibernateUtil.currentSession();
       Transaction tx = session.beginTransaction();
       Query query = session.createQuery("select u from User as u where u.userid = :id");
       query.setInteger("id", id.intValue());
       u = (User) query.uniqueResult();
       tx.commit();
       HibernateUtil.closeSession();
       } catch (HibernateException he) {
       System.out.println("getUser: "+he);
       }
      

      where HibernateUtil is the standard stuff from the manual...so AFAIK the connection should be open.

      I'm using JBoss 4.0.3 sp1, jdk 1.4.2, hibernate 3

      Any ideas? Let me know if you need more info...Thanks.