"WFLYJCA0114: Failed to load datasource class: ..." referencing unused class in JBoss EAP
Environment
- Red Hat JBoss Enterprise Application Platform (EAP) 7.2 (and later)
Issue
-
Encountering a datasource add/deployment failure indicating a missing driver
... "WFLYCTL0412: Required services that are not installed:" => [ "jboss.jdbc-driver.oracle", "jboss.jdbc-driver.oracle" ], "WFLYCTL0180: Services with missing/unavailable dependencies" => [ "org.wildfly.data-source.MyDS is missing [jboss.jdbc-driver.oracle]", "jboss.driver-demander.java:/jdbc/MyDS is missing [jboss.jdbc-driver.oracle]", "org.wildfly.data-source.MyDS is missing [jboss.jdbc-driver.oracle]" ] -
Earlier in the
server.logthe following error was found... ERROR [org.jboss.as.controller.management-operation] ... WFLYCTL0013: Operation ("add") failed - address: ([ ("subsystem" => "datasources"), ("jdbc-driver" => "oracle") ]) - failure description: "WFLYJCA0114: Failed to load datasource class: oracle.jdbc.OracleDriver" -
oracle.jdbc.OracleDriverwas specified as anxa-datasource-classbut no XA pool has been defined so the class should not be used. -
The same configuration worked in older EAP releases (prior to JBoss EAP 7.2).
Resolution
- If creating an XA datasource pool, verify that a valid
<xa-datasource-class>is specified in the relevant entry in the<drivers>configuration (at the bottom of thedatasourcessubsection) or else within the<xa-datasource>configuration. Refer to the XA datasource examples in the JBoss EAP Configuration Guide. - If creating a non-XA datasource pool, remove
<driver-class>and<datasource-class>references (from both the<datasource>and the relevant entry in the<drivers>configuration). JDBC 4 compliant drivers specify their preferred connection provider in the driver JAR'sMETA-INF/services/java.sql.Driverfile. Only if the driver is not JDBC 4 compliant should a provider class be required for non-XA datasource pools. In such cases, consult the 3rd party driver vendor's documentation for an appropriate class. Note that adriver-classwould be preferred rather than adatasource-classwhen a provider class must be specified.
Root Cause
- An invalid
datasource-classorxa-datasource-classwas specified (e.g. in the example above, an Oracle class implementing the Content from docs.oracle.com is not included.java.sql.Driver interface was specified asxa-datasource-classand this class cannot be cast to Content from docs.oracle.com is not included.javax.sql.XADataSource). - The
WFLYJCA0114error is the result of enhanced Content from github.com is not included.validation in EAP 7.2 and later - any explicitly specifieddatasource-classorxa-datasource-classin adriverconfiguration will be loaded for verification.- In EAP releases earlier than EAP 7.2, only explicitly provided
driver-class-nameproperties were validated and invaliddatasource-classorxa-datasource-classproperties were ignored until/unless used (e.g. if an XA pool was specified thexa-datasource-classwould be accessed).
- In EAP releases earlier than EAP 7.2, only explicitly provided
- The
WFLYCTL0412/WFLYCTL0180pair result from the failed driver deployment (since the driver isn't deployed, the datasource which depends on it cannot be deployed).
Diagnostic Steps
For the class mentioned in the "Failed to load" message:
- Verify that the class specified exists in the driver JAR file.
- Verify that the class specified implements the correct interface1. This can often be accomplished using
javap -cp <jar_file> <fully.qualified.class>for the class (and its super-classes or super-interfaces).
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.