java.lang.ClassCastException: oracle.jdbc.driver.OracleResultSetImpl cannot be cast to oracle.jdbc.OracleResultSet in EAP 6
Issue
- Our Test application defines custom hibernate type (by implementing Hibernate UserType) to map the oracle XMLTYPE column.
public Object testGet(ResultSet resultSet, String[] names, Object arg2)
throws HibernateException, SQLException {
Object result = null;
// Required for use inside JBOSS Container
logger.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>resultSet type:" + resultSet.getClass().getName());
if (resultSet instanceof WrappedResultSet) {
WrappedResultSet wrappedRS = (WrappedResultSet) resultSet;
resultSet = wrappedRS.getUnderlyingResultSet();
}
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<UnderlyingResultSet type:" + resultSet.getClass().getName());
try {
OracleResultSet oracleResultSet = (OracleResultSet) resultSet;
OPAQUE op = oracleResultSet.getOPAQUE(names[0]);
if (null != op) {
oracle.xdb.XMLType xt = oracle.xdb.XMLType.createXML(op);
DOMReader reader = new DOMReader();
org.dom4j.Document document = reader.read(xt.getDOM());
result = document.getRootElement();
}
logger.info("Type of resultSet: " + resultSet.getClass().getName());
} catch(Exception ex){
logger.info("Error converting JBOSS Wrapped resultset to Oracle");
ex.printStackTrace();
}
return result;
}
- Above code works fine in
EAP 5.1but breaks inEAP 6.2withClassCastException (log listed below)
2015-04-10 12:06:48,233 INFO [HibernateXMLType] (http-/172.28.125.102:8443-1) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>resultSet type:org.jboss.jca.adapters.jdbc.jdk6.WrappedResultSetJDK6
2015-04-10 12:06:48,233 INFO [HibernateXMLType] (http-/172.28.125.102:8443-1) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<UnderlyingResultSet type:oracle.jdbc.driver.OracleResultSetImpl
2015-04-10 12:06:48,234 INFO [HibernateXMLType] (http-/172.28.125.102:8443-1) Error converting JBOSS Wrapped resultset to Oracle
2015-04-10 12:06:48,235 ERROR [stderr] (http-/172.28.125.102:8443-1) java.lang.ClassCastException: oracle.jdbc.driver.OracleResultSetImpl cannot be cast to oracle.jdbc.OracleResultSet
2015-04-10 12:06:48,235 ERROR [stderr] (http-/172.28.125.102:8443-1) at HibernateXMLType.testGet(HibernateXMLType.java:80)
-
In EAP 6.2 the
resultSettype changed fromoracle.jdbc.OracleResultSettooracle.jdbc.driver.OracleResultSetImpl. Can you provide some suggestions? -
The Oracle driver is not packaged with the app. We've tried configuring the driver as a jar deployment and as a module. For example the module configuration was done under:
/www/redhat/eap-62/modules/com/oracle/jdbc/main -
We added the dependency in the
jboss-deployment-structure.xml:<module name="com.oracle.jdbc" slot="main"/> -
Also configured the container managed datasource.
- The developer has configured two datasources, one with
jdbc6 (testDataSource1)and the other withjdbc7 (testDataSource2)driver. we have never be able to get it working withjdbc7 driver. - If we use the
jdbc7 driverJBoss is complaining about the following exception:
Caused by: java.lang.ClassNotFoundException: oracle.xdb.XMLType from [Module "deployment.ojdbc7-12.1.0.1.0.jar:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.3.Final-redhat-1]
-
If we use the jdbc6 datasource then we are getting error related to
Resultset. -
Note that all jdbc calls are working fine except for
XMLTypeswhen using either data source.
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 6.2.3
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
