title: Transaction/DB problems in asynchronous methods with Seam
body: <p>I have a strange behaviour with Seam 2.2.2, JBoss 5.1, MySQL 5.1.5.1 and MySQL JDBC connector 5.1.12 and asynchronous methods (using quartz) and pojos.</p>
  
  <p>I've got a pool of 10 async threads for various tasks. They normally work fine, performing db queries and updates etc.
  If there is an exception in one async method it doesn't impact the next async method called from the same thread.</p>
  
  <p>But I now have one case where I get this exception in one particular thread:</p>
  
  <pre><code>    012-10-02 05:45:26,743 WARN  [][JDBCExceptionReporter] (er-4) SQL Error: 0, SQLState: null
  2012-10-02 05:45:26,743 ERROR [][JDBCExceptionReporter] (er-4) Transaction is not active: tx=TransactionImple &amp;lt; ac, BasicAction: 7f000001:b824:5069f752:15d status: ActionStatus.ABORT_ONLY &amp;gt;; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImple &amp;lt; ac, BasicAction: 7f000001:b824:5069f752:15d status: ActionStatus.ABORT_ONLY &amp;gt;)
  2012-10-02 05:45:26,743 INFO  [][DefaultLoadEventListener] (er-4) Error performing load command
  org.hibernate.exception.GenericJDBCException: Cannot open connection
          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.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52)
          at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:449)
          at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
          at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161)
          at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1573)
  </code></pre>
  
  <p>After this every time this thread (er-4) is used and a query is executed I get the same exception.
  How can I recover from this and why is this?
  It doesn't matter what method is called by this thread (they are annotated with @Transactional) they all fail because of the GenericJDBCException: Cannot open connection.
  The problem suddenly appeared out of the blue.</p>
  
  <p>I am using db connection pooling and validate the connection before each use (from the deployment descriptor):</p>
  
  <pre><code>  &lt;!--pooling parameters--&gt;
         &lt;min-pool-size&gt;5&lt;/min-pool-size&gt;
         &lt;max-pool-size&gt;100&lt;/max-pool-size&gt;
         &lt;blocking-timeout-millis&gt;5000&lt;/blocking-timeout-millis&gt;
         &lt;idle-timeout-minutes&gt;15&lt;/idle-timeout-minutes&gt;
         &lt;prepared-statement-cache-size&gt;50&lt;/prepared-statement-cache-size&gt;
         &lt;check-valid-connection-sql&gt;select 1 from dual&lt;/check-valid-connection-sql&gt;
  </code></pre>
  
  <p>Is this a problem with my code? with Seam? JBoss? MySQL? JDBC MySQL driver?</p>
  
  <p>Has anyone else experienced similar problems.</p>