Connect ClassCastException when using oracle.jdbc.pool.OracleDataSource

I have a SJSWS 6.1SP6 installation with a functioning JNDI datasource declared. It uses the Oracle ojdbc14.jar implementation of oracle.jdbc.pool.OracleDataSource to create a pool, which I have named sacsdb. This datasource functions well from within a web application deployed on the server when I perform normal JDBC CallableStatement operations; that is as long as I use simple, standard types.

For a particular application, I need to use Oracle's XMLType, delivered from Oracle as xdb.jar, as inputs to some of the CallableStatement procedures. This means that I must create an XMLType instance and set it as a generic object parameter. I use the following code to perform this operation:

XMLType xml = XMLType.createXML(conn, (String)value);

cs.setObject(pos, xml);

where conn is a java.sql.Connection and cs is java.sql.CallableStatement (both of which are Oracle implementations under the hood).

This XMLType creation requires that it be passed an oracle.jdbc.OracleConnection, since it apparently requires some extension that Oracle has provided in their connection implementation.

My problem is that even though I have declared the datasource as implementing oracle.jdbc.pool.OracleDataSource, I do not get an OracleConnection object when I do datasource.getConnection(); instead, it appears that I get com.sun.enterprise.resource.JdbcConnection, as shown in the following exception:

Caused by: java.lang.ClassCastException: com.sun.enterprise.resource.JdbcConnection

at oracle.sql.OpaqueDescriptor.createDescriptor(OpaqueDescriptor.java:68)

at oracle.xdb.XMLType.<init>(XMLType.java:540)

at oracle.xdb.XMLType.createXML(XMLType.java:635)

at com.xerox.xcs.commons.service.procstream.ProcStreamServiceImpl.registerCallable StatementInputParameter(ProcStreamServiceImpl.java:917)

at com.xerox.xcs.commons.service.procstream.ProcStreamServiceImpl.executeCallableS tatement(ProcStreamServiceImpl.java:701)

My JDBC Connection Pool is configured as follows:

- Pool Name: SACSDB

- DataSource Classname: oracle.jdbc.pool.OracleDataSource

- URL: jdbc:oracle:thin:<user>/<passwd>@<host>:1571:<sid>

- user: <user>

- password: <passwd>

I have tried to put the ojdbc14.jar file in the Classpath Suffix and within the JRE's endorsed directory. Under both of these configurations, the datasource worked normally but still threw this exception on XMLType usage. Also, I attempted to put it in the Native Lib Path Prefix, but nothing worked under this condition.

I get the feeling that this is simply a configuration issue but am at a loss as to what else to try... I wonder if there are any other datasource properties that I need to set or if there are any JVM options I need to set to tell the pooling manager which connection class to use...

I need to get this functioning rather quickly. If not, then I need to adjust the code to create the JNDI datasource on application startup. I would rather not do the later as I will lose the ability to configuration / tune it from the web server's admin console.

BTW, this code works fine within my development environment under Tomcat5... Including the XMLTYPE input parameter operations...

Any thoughts?

Jon Brule

[3350 byte] By [jbrulea] at [2007-11-27 7:36:25]
# 1
Sorry, what you are trying to do is not supported in SJS Web Server. It does not provide access to the underlying connection, only to the wrapper, which is com.sun.enterprise.resource.JdbcConnection, which implements javax.sql.Connection, not vendor specific methods.
mr_pickwicka at 2007-7-12 19:16:56 > top of Java-index,Web & Directory Servers,Web Servers...
# 2
Thanks for the quick reply... Do you know if there is any way to coerce the Sun JdbcConnection into its parallel Oracle connection on the fly? Or, do you think it is time that I implement my own datasource creation at application startup?Jon Brule
jbrulea at 2007-7-12 19:16:56 > top of Java-index,Web & Directory Servers,Web Servers...
# 3
It is not possible to do this. There is no support for accessing the underlying connection.You could do this with your own data source wrapper, and provide access to it using a jndi custom resource.
nseguraa at 2007-7-12 19:16:56 > top of Java-index,Web & Directory Servers,Web Servers...