Testing datasource pool connections using CLI in JBoss EAP
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 6
- 7
Issue
- Test JDBC connection to the data source through the JBoss CLI command for standalone or domain configuration
- Verify database connectivity for JBoss EAP
- When we are trying to test DB connection we are getting below error:
"WFLYJCA0040: failed to invoke operation: WFLYJCA0042: failed to match pool. Check JndiName: java:/databasename"
Resolution
Use the following CLI Commands to test the DataSource connections:
Standalone Mode:
-
For XA-DataSource:
/subsystem=datasources/xa-data-source=<DATASOURCE_POOL_NAME>:test-connection-in-pool -
For Non-XA_DataSource:
/subsystem=datasources/data-source=<DATASOURCE_POOL_NAME>:test-connection-in-pool
Domain Mode:
-
For XA-DataSource:
/host=$Host_Controller_Name/server=$Server_Name/subsystem=datasources/xa-data-source=<DATASOURCE_POOL_NAME>:test-connection-in-pool -
For Non-XA-DataSource:
/host=$Host_Controller_Name/server=$Server_Name/subsystem=datasources/data-source=<DATASOURCE_POOL_NAME>:test-connection-in-pool -
For
WFLYJCA0040, check database configuration.
Diagnostic Steps
-
If the host or server (for domain configurations) or the datasource name is incorrect the following error may be reported:
JBAS014807: Management resource '[(\"subsystem\" => \"datasources\")]' not found -
If connectivity cannot be established (e.g. because the database is down/inaccessible) the following error may be reported
WFLYJCA0040: failed to invoke operation: WFLYJCA0047: Connection is not valid- Additional detail should be logged (possibly at
WARNlevel) in theserver.logfor the JVM for which thetest-connectionis performed.
- Additional detail should be logged (possibly at
-
If the datasource is newly created, verify that the relevant JVM has been restarted.
-
Review the JBoss EAP
server.logfor the JVM against which the test is run for further details- Note that some failures may be logged at
WARNlevel soWARNlogging (globally or for theorg.jboss.jcapackage and its sub-packages) should not be suppressed. - If no detail is logged in the
server.logfor the relevant JVM whentest-connectionfails, it is likely thatWARNlogging is suppressed in theloggingsubsystem.
- Note that some failures may be logged at
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.