title: Jboss AS7 connection pool won't reconnect
body: <p>I have the following configuration in my <code>standalone.xml</code>:</p>
  
  <pre><code>&lt;subsystem xmlns="urn:jboss:domain:datasources:1.1"&gt;
      &lt;datasources&gt;
          &lt;datasource jta="true" jndi-name="java:/jdbc/myds" pool-name="CADS" enabled="true" use-java-context="true" use-ccm="true"&gt;
              &lt;connection-url&gt;jdbc:postgresql://db.host/name&lt;/connection-url&gt;
              &lt;driver&gt;postgresql&lt;/driver&gt;
              &lt;new-connection-sql&gt;select 1&lt;/new-connection-sql&gt;
              &lt;pool&gt;
                  &lt;min-pool-size&gt;20&lt;/min-pool-size&gt;
                  &lt;max-pool-size&gt;100&lt;/max-pool-size&gt;
                  &lt;flush-strategy&gt;IdleConnections&lt;/flush-strategy&gt;
              &lt;/pool&gt;
              &lt;security&gt;
                  &lt;user-name&gt;user&lt;/user-name&gt;
                  &lt;password&gt;pwd&lt;/password&gt;
              &lt;/security&gt;
              &lt;validation&gt;
                  &lt;valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker"/&gt;
                  &lt;exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter"/&gt;
              &lt;/validation&gt;
              &lt;timeout&gt;
                  &lt;blocking-timeout-millis&gt;30000&lt;/blocking-timeout-millis&gt;
                  &lt;idle-timeout-minutes&gt;1&lt;/idle-timeout-minutes&gt;
              &lt;/timeout&gt;
              &lt;statement&gt;
                  &lt;track-statements&gt;true&lt;/track-statements&gt;
              &lt;/statement&gt;
          &lt;/datasource&gt;
          &lt;drivers&gt;
              &lt;driver name="postgresql" module="org.postgresql"&gt;
                  &lt;xa-datasource-class&gt;org.postgresql.Driver&lt;/xa-datasource-class&gt;
              &lt;/driver&gt;
          &lt;/drivers&gt;
      &lt;/datasources&gt;
  &lt;/subsystem&gt;
  </code></pre>
  
  <p>If, for some reason, the database stop responding for a second, JBoss can't reconnect and I have to restart the app server.</p>
  
  <p>But, If I change the <code>datasource</code> to <code>xa-datasource</code> (keeping the config as it is in the example) using the <code>org.postgresql.xa.PGXADataSource</code> driver, <strong>it works</strong>.</p>
  
  <p>Thing is: I can't make sense out of this. Correct me if I'm wrong, but <code>xa-datasources</code> are supposed to be used to synchronously commit in more than one database, and that's not the case here. I actually have more than one database configured, but I don't need to sync the transactions between them.</p>
  
  <p>The "default" <code>datasource</code> also seems to have problems with sizing the connection pool. Sometimes, doesn't matter the load of the app, it opens more than 100 connections (even if the limit is 100) and closes them after some seconds. This is hard to reproduce - because it seems random, so, I can't tell for sure that switching to <code>xa-datasource</code> solves this problem too.</p>
  
  <p>Now:</p>
  
  <ul>
  <li>why switching to <code>xa-datasource</code> works?</li>
  <li>what are the implications of doing this?</li>
  <li>why connection pool is going crazy like this?</li>
  </ul>
  
  <hr>
  
  <p>Just to clarify, my test consists in:</p>
  
  <ol>
  <li>start up postgres and the app server;</li>
  <li>do some requests to the application;</li>
  <li>stop the database;</li>
  <li>do some requests to the application - and see that they are not working because it can't open any connections;</li>
  <li>start up the database again;</li>
  <li>do some requests to the application</li>
  </ol>
  
  <p>In the last step, <code>xa-datasource</code> can reconnect with postgres and everything works. <code>datasource</code> can't, and fails forever, load doesn't matter - I have to restart the app server.</p>