Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.0.4
-
None
-
None
Description
I might be missing something here but whenever PlatformOracle9iImpl is attempting to unwrap the underlying connection a DBCP pooled connection (pooled via Tomcat 5.5), it appears to be getting an IllegalAccessException since the class which is holding the wrapped connection is a private inner class (org.apache.commons.dbcp.dbcp.PoolingDriver.PoolGuardConnectionWrapper) so the genericUnwrap is returning null. This still occurs even if I set accessToUnderlyingConnectionAllowed to true on the DBCP data source factory.
Spring has a class which implements this functionality called the CommonsDbcpNativeJdbcExtractor which deals with the successfully by falling back to retrieving the underlying connection from the Database metadata. If I patch PlatformOracle9iImpl accordingly, this works great. Here is the implementation of unwrapConnection which works successfully for me (note, code below is essentially copied from the aforementioned spring code):
/**
- Return an OracleConnection after trying to unwrap from known Connection wrappers.
- @param conn the connection to unwrap (if needed)
- @return OracleConnection or null if not able to unwrap
*/
protected Connection unwrapConnection(Connection conn)
{
Object unwrapped = genericUnwrap(ORA_CONN_CLASS, conn, UNWRAP_CONN_METHOD_NAMES, UNWRAP_CONN_PARAM_TYPES);
try {
// We haven't received a different Connection, so we'll assume that there's
// some additional proxying going on. Let's check whether we get something
// different back from the DatabaseMetaData.getConnection() call.
DatabaseMetaData metaData = conn.getMetaData();
// The following check is only really there for mock Connections
// which might not carry a DatabaseMetaData instance.
if (metaData != null)Unknown macro: { Connection metaCon = metaData.getConnection(); if (metaCon != conn) { // We've received a different Connection there: // Let's retry the native extraction process with it. unwrapped = genericUnwrap(ORA_CONN_CLASS, metaCon, UNWRAP_CONN_METHOD_NAMES, UNWRAP_CONN_PARAM_TYPES); } }} catch (SQLException e)
Unknown macro: { if (logger.isDebugEnabled()) { logger.debug("Failed attempting to unwrap connection via database metadata.", e); } }if (unwrapped == null)
Unknown macro: { // mkalen}return (Connection) unwrapped;
}