Connection Pool Testing with WildFly / JBoss

This article will teach you how to perform Connection Pool testing to validate a Connection against the Database. You will learn how to test a connection both in standalone mode and in domain mode.

Fixing Unable to create connection error

Before deploying your application to a WildFly server, it’s crucial to ensure that your datasource is configured correctly and can establish a connection to the database. This prevents unexpected runtime errors and downtime. Without that, a misconfiguration of your Database connection for JBoss/WildFly will cause the following exception:

2024-07-25 12:08:07,284 WARN  [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (ServerService Thread Pool -- 245) IJ000604: Throwable while attempting to get a new connection: null: javax.resource.ResourceException: IJ031084: Unable to create connection

The above error means that some parameters of your Datasource are not valid. Quite likely, your credentials are not correct. How to verify it?

As you can see from the following screenshot, to test the Database connection pool, you can point to the Runtime Tab and check Server Group | Server | Datasources | Datasource:

wildfly test connection pool

From the Datasource column, select your Datasource, right click on it and select Test.

In order to test the Database connection from the Command Line, you can follow the same approach. You need to point to one Server (where the Datasource is available) and invoke the test-connection-in-pool action:

 /host=master/server=Server1/subsystem=datasources/data-source=mysql_datasource:test-connection-in-pool

If the test fails, consider the following:

  • Check logs: Examine the WildFly server logs for error messages.
  • Verify database connectivity: Ensure the database is reachable and accessible.
  • Review datasource configuration: Verify all parameters are correct.
  • Check firewall rules: Verify that there are no firewall restrictions blocking the connection.

Conclusion

This short wiki discussed how to test the datasource connectivity with WildFly / Jboss application server. If you want to implement Datasource validation, to prevent potential issues caused by invalid connections, check this article: How to validate Database connections in JBoss / WildFly