Testing datasource pool connections using CLI in JBoss EAP

Solution Verified - Updated

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 WARN level) in the server.log for the JVM for which the test-connection is performed.
  • If the datasource is newly created, verify that the relevant JVM has been restarted.

  • Review the JBoss EAP server.log for the JVM against which the test is run for further details

    • Note that some failures may be logged at WARN level so WARN logging (globally or for the org.jboss.jca package and its sub-packages) should not be suppressed.
    • If no detail is logged in the server.log for the relevant JVM when test-connection fails, it is likely that WARN logging is suppressed in the logging subsystem.
Components
Category

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.