Tomcat, Oracle, connection pooling, BLOBs

From: Nikolaus Rumm (spambox_at_kephera.com)
Date: 12/21/04


Date: 21 Dec 2004 06:41:46 -0800

I have a rather strange problem with Tomcat's connection pooling and
the Oracle JDBC driver when using BLOBs that seems to be related to
class loading.

My configuration:
Tomcat 5.0.27
Oracle 9i
ojdbc14.jar is in $CATALINA_HOME/common/lib (and nowhere else)
The datasource is configured in server.xml

Everything works perfectly as long as I don't configure the datasource
in the server.xml file (including reading/writing BLOBs).

Once I use the datasource configuration in server.xml everything
except Oracle's BLOB implementation works (means: I can access the
tables, insert, select etc., but I can't read/write BLOBs)).

The problem is with class loading:

System.out.println(getConnection() instanceof
oracle.jdbc.driver.OracleConnection);
System.out.println(getConnection().getClass().getName());

results in:
false
oracle.jdbc.driver.OracleConnection

So the connection is of the expected type, but the type has been
loaded with the wrong class loader. This leads to a ClassCastException
in the Oracle JDBC driver (createTemporary()).
As I told you the JDBC driver is in common/lib and nowhere else, so
the class should be available in the application code.

Any hints ?