title: How to fix " No managed connections available within configured blocking timeout (60000 [ms]) "
body: <p>I have deployed <code>java</code> application on <code>wildfly-15.0.1.FINAl</code> server.I am using <code>OJDBC 12.1.0.2.0</code> driver.</p>
  
  <pre><code>&lt;datasource jndi-name="java:/DS_APP" pool-name="APP" enabled="true" use-java-context="true"&gt;
          &lt;connection-url&gt;jdbc:oracle:thin:@localhost:1521:MYDB&lt;/connection-url&gt;      
          &lt;driver&gt;OracleJDBCDriver&lt;/driver&gt;
          &lt;transaction-isolation&gt;TRANSACTION_READ_COMMITTED&lt;/transaction-isolation&gt;
          &lt;pool&gt;
               &lt;min-pool-size&gt;3&lt;/min-pool-size&gt;
               &lt;max-pool-size&gt;200&lt;/max-pool-size&gt;
          &lt;/pool&gt;
          &lt;security&gt;
               &lt;security-domain&gt;Password4APP&lt;/security-domain&gt;
          &lt;/security&gt;
          &lt;validation&gt;
              &lt;valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"/&gt;
              &lt;exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"/&gt;
          &lt;/validation&gt;
          &lt;timeout&gt;
              &lt;blocking-timeout-millis&gt;60000&lt;/blocking-timeout-millis&gt;
              &lt;idle-timeout-minutes&gt;15&lt;/idle-timeout-minutes&gt;
          &lt;/timeout&gt;
          &lt;statement&gt;
              &lt;track-statements&gt;true&lt;/track-statements&gt;
              &lt;prepared-statement-cache-size&gt;100&lt;/prepared-statement-cache-size&gt;
          &lt;/statement&gt;
      &lt;/datasource&gt;
  </code></pre>
  
  <p>There was a period when my application could not get database connection and was logging errors like this</p>
  
  <pre><code>Caused by: java.sql.SQLException: javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:/DS_APP
      at org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:146) ~[?:?]
      at org.jboss.as.connector.subsystems.datasources.WildFlyDataSource.getConnection(WildFlyDataSource.java:64) ~[?:?]
      at ge.app.ws.util.DbManager.getDatabaseConnection(DbManager.java:55) ~[classes:?]
      ... 2 more
  Caused by: javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:/DS_APP
      at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:690) ~[?:?]
      at org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.getManagedConnection(TxConnectionManagerImpl.java:440) ~[?:?]
      at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:789) ~[?:?]
      at org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:138) ~[?:?]
      at org.jboss.as.connector.subsystems.datasources.WildFlyDataSource.getConnection(WildFlyDataSource.java:64) ~[?:?]
      at ge.app.ws.util.DbManager.getDatabaseConnection(DbManager.java:55) ~[classes:?]
      ... 2 more
  Caused by: javax.resource.ResourceException: IJ000655: No managed connections available within configured blocking timeout (60000 [ms])
      at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.getConnection(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:570) ~[?:?]
      at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getSimpleConnection(AbstractPool.java:632) ~[?:?]
      at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getConnection(AbstractPool.java:604) ~[?:?]
      at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:624) ~[?:?]
      at org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.getManagedConnection(TxConnectionManagerImpl.java:440) ~[?:?]
      at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:789) ~[?:?]
      at org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:138) ~[?:?]
      at org.jboss.as.connector.subsystems.datasources.WildFlyDataSource.getConnection(WildFlyDataSource.java:64) ~[?:?]
      at ge.app.ws.util.DbManager.getDatabaseConnection(DbManager.java:55) ~[classes:?]
      ... 2 more
  </code></pre>
  
  <p>I read many blogs about this error, but my point is different.
  From blogs I found some problem issues:</p>
  
  <ol>
  <li>Maybe you have Connection leak. You are not closing connections
  
  <ul>
  <li>What I done: I checked every line of my code and I am sure every 
  <code>Connection</code> and <code>CallableStatement</code> are closing.</li>
  </ul></li>
  <li>Maybe all connections from the pool are already in use, Try to grow your connection pool size which is default 20
  
  <ul>
  <li>What I done: When there was this problem, I checked connections on database side and there was no active connection, all connections were inactive, also I have 200 connections in pool which is so many, I have maximum 30 active session at the same time and I have 60 Second time out to wait until connections from pool is free. </li>
  </ul></li>
  </ol>
  
  <p>When I restarted my <code>Wildfly</code> server the problem solved, but I am interested in why this errors happened, if there can be this errors in the future(I think they will occur again) and how to avoid them?</p>