You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by WM C <do...@live.com> on 2009/11/28 11:18:30 UTC

data source factory

Hi -

I am upgrading a working web app from Tomcat 5.0 to 5.5, and encounter the following data source problem.

According to Apache web site, for Tomcat 5.5 configuration, I should use

       factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory

in <Resource> for datasource configuration.

It works okay for the most jdbc part, except that I got an exception of

     java.lang.ClassCastException: oracle.sql.CLOB 

at the line oracle.sql.CLOB clob = (oracle.sql.CLOB) rs.getClob(...) in one DAO method.

Since the code works in Tomcat5.0, so I changed factory attribute back to
 
     factory="org.apache.commons.dbcp.BasicDataSourceFactory"

and everything works fine now. No exception thrown anymore.

Since this is a kind of a desperate "trail and error" after scratching my head for a day (true Black Friday :( )
so even though it works, I am wondering if I should use the DataSourceFactory meant to be used for Tomcat 5.0, and if there will be any bad consequences later on.

Thanks a lot for any comments - I appreciate!

William 

 		 	   		  
_________________________________________________________________
Hotmail: Trusted email with Microsoft's powerful SPAM protection.
http://clk.atdmt.com/GBL/go/177141664/direct/01/
http://clk.atdmt.com/GBL/go/177141664/direct/01/

Re: data source factory

Posted by Mark Thomas <ma...@apache.org>.
WM C wrote:
> Hi Mark - Thanks for the reply, here is the info you asked:
> 
>> Where is the oracle jdbc driver jar located?
> in web-inf/lib  (I am using ojdbc14.jar - btw, according to some forum messages, seems it got problem with jdk5.0, but that's a different story) 
> 
>> Where are the commons-dbcp and commons-pool JARs located?
> in web-inf/lib
> 
>> Exactly which versions of Tomcat, commons-pool and commons-dbcp are you using?
> it's apache-tomcat-5.5.17
> commoms-dbcp version: Implementation-Version: 1.2.1 (got it from MENIFEST file, Build-Jdk: 1.4.1_02 - maybe that's the reason)
> commons-pool version: Implementation-Version: 1.3
> 
>> What is the full stack trace?
> I did not have it, it went to IDE console, did not save. (but it did not generate much info using e.printStackTrace)
> 
>> What is your complete resource definition?
> <Resource name="jdbc/myDS" auth="Container"
>         type="javax.sql.DataSource" 
>         maxActive="50" maxIdle="30" maxWait="10000" 
>         username="xxx" password="xxxxx"
>         driverClassName="oracle.jdbc.driver.OracleDriver"
>         factory="org.apache.commons.dbcp.BasicDataSourceFactory"
>         url="jdbc:oracle:thin:@nnn.nnn.nnn.nn:1521:xxxx"
>         removeAbandoned="true" />
> 
>> Which file has this resource definition been placed in?
> at context.xml in META-INF
> 
> By the way, I am using Eclipse 3.2, jdk1.5.0_14 - I set compiler compliance level 5.0, but set generated .class compatibility to 1.4 and source compatibility to 1.4 .
> 
> Thanks a lot for the help!

Given all of that, stick with your working configuration and don't try
switching to the re-packaged Tomcat pooling (it is the same code so in
terms of functionality the only difference is the library versions).

I would consider upgrading to commons-pool-1.5.4 and the soon to be
released commons-dbcp 1.3 (1.4 will be released at the same time and is
the same code but with support for JDBC4 which requires a 1.6 JDK) for
some performance improvements but if you don't need the extra
performance and your config works you can happily stay where you are.

Mark

> 
> William
> 
> 
>> Date: Sat, 28 Nov 2009 10:29:25 +0000
>> From: markt@apache.org
>> To: users@tomcat.apache.org
>> Subject: Re: data source factory
>>
>> WM C wrote:
>>> Hi -
>>>
>>> I am upgrading a working web app from Tomcat 5.0 to 5.5, and encounter the following data source problem.
>>>
>>> According to Apache web site, for Tomcat 5.5 configuration, I should use
>>>
>>>        factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory
>>>
>>> in <Resource> for datasource configuration.
>>>
>>> It works okay for the most jdbc part, except that I got an exception of
>>>
>>>      java.lang.ClassCastException: oracle.sql.CLOB 
>>>
>>> at the line oracle.sql.CLOB clob = (oracle.sql.CLOB) rs.getClob(...) in one DAO method.
>>>
>>> Since the code works in Tomcat5.0, so I changed factory attribute back to
>>>  
>>>      factory="org.apache.commons.dbcp.BasicDataSourceFactory"
>>>
>>> and everything works fine now. No exception thrown anymore.
>>>
>>> Since this is a kind of a desperate "trail and error" after scratching my head for a day (true Black Friday :( )
>>> so even though it works, I am wondering if I should use the DataSourceFactory meant to be used for Tomcat 5.0, and if there will be any bad consequences later on.
>>>
>>> Thanks a lot for any comments - I appreciate!
>> Where is the oracle jdbc driver jar located?
>> Where are the commons-dbcp and commons-pool JARs located?
>> Exactly which versions of Tomcat, commons-pool and commons-dbcp are you
>> using?
>> What is the full stack trace?
>> What is your complete resource definition?
>> Which file has this resource definition been placed in?
>>
>> Do you want to use Tomcat's built-in connection pool or are you happy
>> with anything as long as it works?
>>
>> Mark
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>  		 	   		  
> _________________________________________________________________
> Windows 7: I wanted simpler, now it's simpler. I'm a rock star.
> http://www.microsoft.com/Windows/windows-7/default.aspx?h=myidea?ocid=PID24727::T:WLMTAGL:ON:WL:en-US:WWL_WIN_myidea:112009




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


RE: data source factory

Posted by WM C <do...@live.com>.
Hi Mark - Thanks for the reply, here is the info you asked:

> Where is the oracle jdbc driver jar located?
in web-inf/lib  (I am using ojdbc14.jar - btw, according to some forum messages, seems it got problem with jdk5.0, but that's a different story) 

> Where are the commons-dbcp and commons-pool JARs located?
in web-inf/lib

> Exactly which versions of Tomcat, commons-pool and commons-dbcp are you using?
it's apache-tomcat-5.5.17
commoms-dbcp version: Implementation-Version: 1.2.1 (got it from MENIFEST file, Build-Jdk: 1.4.1_02 - maybe that's the reason)
commons-pool version: Implementation-Version: 1.3

> What is the full stack trace?
I did not have it, it went to IDE console, did not save. (but it did not generate much info using e.printStackTrace)

> What is your complete resource definition?
<Resource name="jdbc/myDS" auth="Container"
        type="javax.sql.DataSource" 
        maxActive="50" maxIdle="30" maxWait="10000" 
        username="xxx" password="xxxxx"
        driverClassName="oracle.jdbc.driver.OracleDriver"
        factory="org.apache.commons.dbcp.BasicDataSourceFactory"
        url="jdbc:oracle:thin:@nnn.nnn.nnn.nn:1521:xxxx"
        removeAbandoned="true" />

> Which file has this resource definition been placed in?
at context.xml in META-INF

By the way, I am using Eclipse 3.2, jdk1.5.0_14 - I set compiler compliance level 5.0, but set generated .class compatibility to 1.4 and source compatibility to 1.4 .

Thanks a lot for the help!

William


> Date: Sat, 28 Nov 2009 10:29:25 +0000
> From: markt@apache.org
> To: users@tomcat.apache.org
> Subject: Re: data source factory
> 
> WM C wrote:
> > Hi -
> > 
> > I am upgrading a working web app from Tomcat 5.0 to 5.5, and encounter the following data source problem.
> > 
> > According to Apache web site, for Tomcat 5.5 configuration, I should use
> > 
> >        factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory
> > 
> > in <Resource> for datasource configuration.
> > 
> > It works okay for the most jdbc part, except that I got an exception of
> > 
> >      java.lang.ClassCastException: oracle.sql.CLOB 
> > 
> > at the line oracle.sql.CLOB clob = (oracle.sql.CLOB) rs.getClob(...) in one DAO method.
> > 
> > Since the code works in Tomcat5.0, so I changed factory attribute back to
> >  
> >      factory="org.apache.commons.dbcp.BasicDataSourceFactory"
> > 
> > and everything works fine now. No exception thrown anymore.
> > 
> > Since this is a kind of a desperate "trail and error" after scratching my head for a day (true Black Friday :( )
> > so even though it works, I am wondering if I should use the DataSourceFactory meant to be used for Tomcat 5.0, and if there will be any bad consequences later on.
> > 
> > Thanks a lot for any comments - I appreciate!
> 
> Where is the oracle jdbc driver jar located?
> Where are the commons-dbcp and commons-pool JARs located?
> Exactly which versions of Tomcat, commons-pool and commons-dbcp are you
> using?
> What is the full stack trace?
> What is your complete resource definition?
> Which file has this resource definition been placed in?
> 
> Do you want to use Tomcat's built-in connection pool or are you happy
> with anything as long as it works?
> 
> Mark
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
 		 	   		  
_________________________________________________________________
Windows 7: I wanted simpler, now it's simpler. I'm a rock star.
http://www.microsoft.com/Windows/windows-7/default.aspx?h=myidea?ocid=PID24727::T:WLMTAGL:ON:WL:en-US:WWL_WIN_myidea:112009

Re: data source factory

Posted by Mark Thomas <ma...@apache.org>.
WM C wrote:
> Hi -
> 
> I am upgrading a working web app from Tomcat 5.0 to 5.5, and encounter the following data source problem.
> 
> According to Apache web site, for Tomcat 5.5 configuration, I should use
> 
>        factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory
> 
> in <Resource> for datasource configuration.
> 
> It works okay for the most jdbc part, except that I got an exception of
> 
>      java.lang.ClassCastException: oracle.sql.CLOB 
> 
> at the line oracle.sql.CLOB clob = (oracle.sql.CLOB) rs.getClob(...) in one DAO method.
> 
> Since the code works in Tomcat5.0, so I changed factory attribute back to
>  
>      factory="org.apache.commons.dbcp.BasicDataSourceFactory"
> 
> and everything works fine now. No exception thrown anymore.
> 
> Since this is a kind of a desperate "trail and error" after scratching my head for a day (true Black Friday :( )
> so even though it works, I am wondering if I should use the DataSourceFactory meant to be used for Tomcat 5.0, and if there will be any bad consequences later on.
> 
> Thanks a lot for any comments - I appreciate!

Where is the oracle jdbc driver jar located?
Where are the commons-dbcp and commons-pool JARs located?
Exactly which versions of Tomcat, commons-pool and commons-dbcp are you
using?
What is the full stack trace?
What is your complete resource definition?
Which file has this resource definition been placed in?

Do you want to use Tomcat's built-in connection pool or are you happy
with anything as long as it works?

Mark




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