[
https://issues.redhat.com/browse/WFLY-14436?page=com.atlassian.jira.plugi...
]
Sudeshna Sur updated WFLY-14436:
--------------------------------
Summary: Improve error for incorrect class for xa-datasource-class, etc. (was:
[GSS](7.3.z) Improve error for incorrect class for xa-datasource-class, etc.)
Improve error for incorrect class for xa-datasource-class, etc.
---------------------------------------------------------------
Key: WFLY-14436
URL:
https://issues.redhat.com/browse/WFLY-14436
Project: WildFly
Issue Type: Enhancement
Components: Server
Reporter: Sudeshna Sur
Assignee: Sudeshna Sur
Priority: Minor
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:
{noformat}
... 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"
{noformat}
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.
{noformat}
... [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)
{noformat}
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}}:
{code:xml}
<datasource jndi-name="java:jboss/datasources/oracle"
pool-name="Oracle" enabled="true" jta="true">
...
<driver>oracle</driver>
<security>
...
</security>
</datasource>
...
<drivers>
<driver name="oracle" module="com.oracle">
<xa-datasource-class>oracle.jdbc.OracleDriver</xa-datasource-class>
</driver>
...
</drivers>
{code}
--
This message was sent by Atlassian Jira
(v8.13.1#813001)