You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jo...@noaa.gov on 2009/02/12 00:41:50 UTC

strange problem w/ connection pool and Oracle

Hello All,

I'm having a rather strange problem using Oracle-specific types obtained
from a connection pool defined my my context.xml.  I'm reading the
ResultSet w/ getObject, but then when I try to cast the Object to the
correct type, I see:

Cause: java.lang.ClassCastException: oracle.sql.STRUCT cannot be cast to
oracle.sql.STRUCT

Strangely, using a DataSource configured via Spring works fine.  I've
listed the snippet from my context.xml defining the pool that doesn't
work and the one for my Spring DataSource that does.

Can someone please help me understand what's going on here?

Thanks!

--john

context.xml:
<Resource name="jdbc/DEVEL"
          type="javax.sql.DataSource"
          auth="Container"
          username="username"
          password="password"
          driverClassName="oracle.jdbc.OracleDriver"
          url="jdbc:oracle:thin:@myhostname:1521:DB"
          maxActive="8"
          maxIdle="4"/>



applicationContext.xml:

    <bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
      <property name="driverClassName" value="oracle.jdbc.OracleDriver"/>
      <property name="url" value="jdbc:oracle:thin:@myhostname:1521:DB"/>
      <property name="username" value="username"/>
      <property name="password" value="password"/>
   </bean>
 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: strange problem w/ connection pool and Oracle

Posted by ovidiu asiminei <ov...@gmail.com>.
Hi John,

This is my context.xml

<!--
    <Valve
className="org.apache.catalina.valves.CometConnectionManagerValve" />
    -->
         <Resource name="jdbc/dev"
                        auth="Container"
                scope="Shareable"
                type="oracle.jdbc.pool.OracleDataSource"
                driverclassname="oracle.jdbc.pool.OracleDataSource"
                factory="oracle.jdbc.pool.OracleDataSourceFactory"
                connectionCachingEnabled="true"
                connectionCacheName="vvvPool"
                connectionCacheProperties="{MaxStatementsLimit=10,
InitialLimit=10, ConnectionWaitTimeout=180, MaxLimit=80, MinLimit=10,
PropertyCheckInterva
l=180, InactivityTimeout=1800}"
                url="jdbc:oracle:thin:@db.example.com:1521:vvvvv"
                user="yyyy"
                password="cccccc" />

</Context>


In my tomcat lib directory  ( /tomcat/lib )  I have a copy of the Oracle
JDBC jar ( ojdbc14_10g.jar )

Regards,

Ovidiu

On Wed, Feb 11, 2009 at 5:41 PM, <Jo...@noaa.gov> wrote:

> Hello All,
>
> I'm having a rather strange problem using Oracle-specific types obtained
> from a connection pool defined my my context.xml.  I'm reading the
> ResultSet w/ getObject, but then when I try to cast the Object to the
> correct type, I see:
>
> Cause: java.lang.ClassCastException: oracle.sql.STRUCT cannot be cast to
> oracle.sql.STRUCT
>
> Strangely, using a DataSource configured via Spring works fine.  I've
> listed the snippet from my context.xml defining the pool that doesn't
> work and the one for my Spring DataSource that does.
>
> Can someone please help me understand what's going on here?
>
> Thanks!
>
> --john
>
> context.xml:
> <Resource name="jdbc/DEVEL"
>          type="javax.sql.DataSource"
>          auth="Container"
>          username="username"
>          password="password"
>          driverClassName="oracle.jdbc.OracleDriver"
>          url="jdbc:oracle:thin:@myhostname:1521:DB"
>          maxActive="8"
>          maxIdle="4"/>
>
>
>
> applicationContext.xml:
>
>    <bean id="dataSource"
> class="org.springframework.jdbc.datasource.DriverManagerDataSource">
>      <property name="driverClassName" value="oracle.jdbc.OracleDriver"/>
>      <property name="url" value="jdbc:oracle:thin:@myhostname:1521:DB"/>
>      <property name="username" value="username"/>
>      <property name="password" value="password"/>
>   </bean>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
ovidiu asiminei

Re: strange problem w/ connection pool and Oracle

Posted by John Cartwright <Jo...@noaa.gov>.
Thanks to all who responded.  Chuck seemed to hit the nail on the head - 
as soon as I removed the duplicate JDBC driver from the WEB-INF/lib, the 
problem went away.  I didn't intend to have the duplicate driver there, 
it was the result of omitting the <scope>provided</scope> in my 
pom.xml.  However, I wouldn't have associated the strange looking class 
cast exception w/ the different classloaders.

Thanks again for the help!

--john


Caldarale, Charles R wrote:
>> From: John.C.Cartwright@noaa.gov [mailto:John.C.Cartwright@noaa.gov]
>> Subject: strange problem w/ connection pool and Oracle
>>
>> Cause: java.lang.ClassCastException: oracle.sql.STRUCT cannot
>> be cast to oracle.sql.STRUCT
>>     
>
> This is a classic symptom of having a class file loaded by two different classloaders; despite having the same names, they are not the same class, due to the different classloaders.
>
> Check your webapp's lib directory to see if there's a copy of the Oracle JDBC jar lurking in there; you can't have it in the webapp if Tomcat is managing the connection pool for you.
>
>  - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: strange problem w/ connection pool and Oracle

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: John.C.Cartwright@noaa.gov [mailto:John.C.Cartwright@noaa.gov]
> Subject: strange problem w/ connection pool and Oracle
>
> Cause: java.lang.ClassCastException: oracle.sql.STRUCT cannot
> be cast to oracle.sql.STRUCT

This is a classic symptom of having a class file loaded by two different classloaders; despite having the same names, they are not the same class, due to the different classloaders.

Check your webapp's lib directory to see if there's a copy of the Oracle JDBC jar lurking in there; you can't have it in the webapp if Tomcat is managing the connection pool for you.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org