Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-21001

[GSS](7.3.z) Improve error for incorrect class for xa-datasource-class, etc.



    • Enhancement
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Deferred
    • 7.2.0.GA, 7.3.0.GA, 7.3.6.GA
    • None
    • Server
    • None


      If a driver class (a class implementing java.sql.Driver) is specified as an xa-datasource-class in a driver configuration (in [standalone*/domain].xml), a generic error is reported:

      ... ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 43) WFLYCTL0013: Operation ("add") failed - address: ([
          ("subsystem" => "datasources"),
          ("jdbc-driver" => "oracle")
      ]) - failure description: "WFLYJCA0114: Failed to load datasource class: oracle.jdbc.OracleDriver"

      A similar sort of (generic) failure will arise if a driver class is specified as a <datasource-class> (though it is not typical to specify a non-XA datasource class).

      It would be more helpful to provide something descriptive indicating that the class cannot be cast to javax.sql.XADataSource which is the underlying reason for the failure - OracleDriver implements the java.sql.Driver interface instead of javax.sql.XADataSource or javax.sql.DataSource. There is a class cast exception raised at a low level - as captured by a Byteman rule (for exception exit from org.jboss.as.connector.subsystems.datasources.JdbcDriverAdd) - and we should know the type to which cast is attempted in the context of the code below.

      ... [BMAN] WFLYJCA0114: Failed to load datasource class: oracle.jdbc.OracleDriver
      ... org.jboss.as.controller.OperationFailedException: WFLYJCA0114: Failed to load datasource class: oracle.jdbc.OracleDriver [ "WFLYJCA0114: Failed to load datasource class: oracle.jdbc.OracleDriver" ]
      ... 	at org.jboss.as.connector.subsystems.datasources.JdbcDriverAdd.performRuntime(JdbcDriverAdd.java:128)
      ... 	at org.jboss.as.controller.AbstractAddStepHandler.performRuntime(AbstractAddStepHandler.java:338)
      ... 	at org.jboss.as.controller.AbstractAddStepHandler$1.execute(AbstractAddStepHandler.java:159)
      ... 	at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:999)
      ... 	at org.jboss.as.controller.AbstractOperationContext.processStages(AbstractOperationContext.java:743)
      ... 	at org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:467)
      ... 	at org.jboss.as.controller.ParallelBootOperationStepHandler$ParallelBootTask.run(ParallelBootOperationStepHandler.java:384)
      ... 	at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
      ... 	at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982)
      ... 	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
      ... 	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1348)
      ... 	at java.lang.Thread.run(Thread.java:748)
      ... 	at org.jboss.threads.JBossThread.run(JBossThread.java:485)
      ... Caused by: java.lang.ClassCastException: class oracle.jdbc.OracleDriver
      ... 	at java.lang.Class.asSubclass(Class.java:3404)
      ... 	at org.jboss.as.connector.subsystems.datasources.JdbcDriverAdd.performRuntime(JdbcDriverAdd.java:126)

      This type of misconfiguration (specifying a driver class as an xa-datasource-class) could go undetected prior to 7.2 as there was no attempt to instantiate the class (e.g. the xa-datasource-class) unless a pool of the relevant type (an xa-datasource pool) was declared. The resolution is to specify an Oracle implementation class that implements the relevant interface (usually javax.sql.XADataSource) or to remove the xa-datasource-class (e.g. if no xa-datasource pool is to be used) or datasource-class (for non-XA pools neither a driver nor datasource class implementation is usually needed for JDBC 4 compliant implementations).

      To reproduce, configuration like the below can be used in standalone*.xml:

                      <datasource jndi-name="java:jboss/datasources/oracle" pool-name="Oracle" enabled="true" jta="true">
                          <driver name="oracle" module="com.oracle">



        Issue Links



              ssur@redhat.com Sudeshna Sur
              rhn-support-sfikes Stephen Fikes
              0 Vote for this issue
              7 Start watching this issue