JBoss run out of Connections ? here is how to fix it

Have you got No ManagedConnections available error message ?

... javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:jboss/datasources/MyDataSource
... javax.resource.ResourceException: IJ000655: No managed connections available within configured blocking timeout (30000 [ms])

In this tutorial we will learn which are the possible causes to this problem.

# 1  Your connection pool is too small

Increase the max number of connections in your datasource configuration (default is 20):


To find the optimal pool size, it is recommended to monitor the Maximum amount of connection requested, which is available through the MaxUsedCount attribute:


It is recommended that you set the max-pool-size around 15-20% higher than the MaxUsedCount under load.

# 2  Need longer timeouts.  If the application server has reached the max-pool-size, it will wait up to the blocking-timeout-wait-millis . When your SQL statements are taking too long, it can be worth increasing the blocking timeout from default 30000 in your datasource configuration:


# 3 Are you closing your connections in the finally method ? (If not your job is really in danger )

finally {
    if (resultSet != null)
    if (statement != null)


It can be helpful to trace Database connections so that you find the piece of code causing pool exaustion. Check the following article to learn how to trace your Datasource connections: How to trace JDBC statements with JBoss and WildFly

# 4 Check the CPU usage of your application server

If your application server is hanging, due to CPU or memory issues, the threads used to manage Connections to the database may delay the return of Connections. This, in turn, can lead to Connection Pool exhaustion.

Check this tutorial to learn how to monitor the CPU usage of JBoss / WildFly: How to monitor JBoss CPU usage like a pro