title: Connection is not associated with a managed connection.org.jboss.resource.adapter.jdbc.jdk6.WrappedConnectionJDK6
body: <p>I am using Hibernate on a JBoss server. I get the error below.</p>
  
  <p>The error happens when I try to connect to the database for the second time in the same sesssion.</p>
  
  <p>Also I get the error "Closing connection for you. Please close your connection".</p>
  
  <pre><code>    14:28:37,869 ERROR [HibernateUtil] HibernateException  occurred in executeQuery  method   in  HibernateUtil class 
      org.hibernate.exception.GenericJDBCException: could not execute query
      at   org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126)
      at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114)
      at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
      at org.hibernate.loader.Loader.doList(Loader.java:2231)
      at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
      at org.hibernate.loader.Loader.list(Loader.java:2120)
      at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
      at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361)
      at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
      at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1148)
      at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
      at com.a.amc.dao.utils.HibernateUtil.executeQuery(HibernateUtil.java:154)
      at com.a.amc.service.impl.CityServiceImpl.isCityExists(CityServiceImpl.java:142)
      at com.a.amc.service.impl.CityServiceImpl.addCity(CityServiceImpl.java:38)
      at com.a.amc.web.actions.CityAction.addCity(CityAction.java:50)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
  
  14:28:37,869 ERROR [JDBCTransaction] Could not toggle autocommit
  java.sql.SQLException: Connection is not associated with a managed connection.org.jboss.resource.adapter.jdbc.jdk6.WrappedConnectionJDK6@1269ca1
      at org.jboss.resource.adapter.jdbc.WrappedConnection.lock(WrappedConnection.java:81)
      at org.jboss.resource.adapter.jdbc.WrappedConnection.setAutoCommit(WrappedConnection.java:454)
      at org.hibernate.transaction.JDBCTransaction.toggleAutoCommit(JDBCTransaction.java:228)
      at org.hibernate.transaction.JDBCTransaction.rollbackAndResetAutoCommit(JDBCTransaction.java:220)
      at org.hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction.java:196)
      at com.a.amc.dao.utils.HibernateUtil.executeQuery(HibernateUtil.java:159)
      at com.a.amc.service.impl.CityServiceImpl.isCityExists(CityServiceImpl.java:142)
      at com.a.amc.service.impl.CityServiceImpl.addCity(CityServiceImpl.java:38)
      at com.a.amc.web.actions.CityAction.addCity(CityAction.java:50)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
  
  14:28:37,869 ERROR [JDBCTransaction] JDBC rollback failed
  java.sql.SQLException: Connection is not associated with a managed connection.org.jboss.resource.adapter.jdbc.jdk6.WrappedConnectionJDK6@1269ca1
      at org.jboss.resource.adapter.jdbc.WrappedConnection.lock(WrappedConnection.java:81)
      at org.jboss.resource.adapter.jdbc.WrappedConnection.rollback(WrappedConnection.java:496)
      at org.hibernate.transaction.JDBCTransaction.rollbackAndResetAutoCommit(JDBCTransaction.java:217)
      at org.hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction.java:196)
      at com.a.amc.dao.utils.HibernateUtil.executeQuery(HibernateUtil.java:159)
      at com.a.amc.service.impl.CityServiceImpl.isCityExists(CityServiceImpl.java:142)
      at com.a.amc.service.impl.CityServiceImpl.addCity(CityServiceImpl.java:38)
      at com.a.amc.web.actions.CityAction.addCity(CityAction.java:50)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
  
  14:28:37,869 ERROR [CityServiceImpl] Exception  occurred in isCityExists method in  CityServiceImpl
  org.hibernate.TransactionException: JDBC rollback failed
      at org.hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction.java:204)
      at com.a.amc.dao.utils.HibernateUtil.executeQuery(HibernateUtil.java:159)
      at com.a.amc.service.impl.CityServiceImpl.isCityExists(CityServiceImpl.java:142)
      at com.a.amc.service.impl.CityServiceImpl.addCity(CityServiceImpl.java:38)
      at com.a.amc.web.actions.CityAction.addCity(CityAction.java:50)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
  </code></pre>
  
  <p>What could be the cause, and how do I solve this situation?</p>