You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Caldarale, Charles R" <Ch...@unisys.com> on 2008/10/09 18:35:37 UTC

RE: dbcp error with java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.PoolingDataSource

> From: Ziggy [mailto:ziggy25@gmail.com]
> Sent: 2008 October 09, Thursday 11:12
> org.apache.tomcat.dbcp.dbcp.PoolingDataSource
>
> I have placed the jdbc driver on both the following directories
> [code]
> $TOMCAT_HOME/common/lib/
> $APPLICATION_ROOT_DIR/WEB-INF/lib/
> [/code]

Never, never, never put the same class(es) in more than one location in a given branch of the classloader tree.

Since you're using Tomcat to manage the DB connection pool, the .jar file containing the JDBC driver classes must be placed in common/lib.

 - 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 start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: dbcp error with java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.PoolingDataSource

Posted by Zdeněk Vráblík <zd...@vrablik.org>.
HI,
I am using a bit different connection configuration to get OracleConnection:
<Resource name="poolname" auth="Container"
type="oracle.jdbc.pool.OracleDataSource"
factory="oracle.jdbc.pool.OracleDataSourceFactory"
connectionCachingEnabled="true"
user="DB" password="DB"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@192.168.100.1:1521:ORCL"
removeAbandoned="true"
removeAbandonedTimeout="30"
maxActive="20"
maxIdle="10" maxwait="-1"/>

I am using Tomcat 6.

Regards,
Zdenek
On Fri, Oct 10, 2008 at 1:59 PM, Ziggy <zi...@gmail.com> wrote:
> Hi,
>
> I am really stuck with the tomcat connection pool as its the application
> server that i am using.
> How does the oracle connection pool work? Could you point me to some info
> somewhere so that i can read about it.
>
> Thanks
>
> On Fri, Oct 10, 2008 at 2:51 PM, Christopher Schultz <
> chris@christopherschultz.net> wrote:
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Ziggy,
>>
>> Ziggy wrote:
>> > The problem i am getting now is that i still cannot cast the class
>> properly
>> > to get the underlying connection.
>>
>> Your best bet is to use standard JDBC API calls instead of trying to use
>> Oracle's proprietary APIs. You may have to use Oracle's connection
>> pooling instead of Tomcat's.
>>
>> - -chris
>>
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.9 (MingW32)
>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>>
>> iEYEARECAAYFAkjvXeIACgkQ9CaO5/Lv0PB2vQCfb8amv7/X/UPq6VBllTKh/awT
>> CUIAnRTeS2VG3c6ExUUvagIn67tZPJLi
>> =yyGE
>> -----END PGP SIGNATURE-----
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>

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


Re: dbcp error with java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.PoolingDataSource

Posted by Ziggy <zi...@gmail.com>.
Hi,

I am really stuck with the tomcat connection pool as its the application
server that i am using.
How does the oracle connection pool work? Could you point me to some info
somewhere so that i can read about it.

Thanks

On Fri, Oct 10, 2008 at 2:51 PM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Ziggy,
>
> Ziggy wrote:
> > The problem i am getting now is that i still cannot cast the class
> properly
> > to get the underlying connection.
>
> Your best bet is to use standard JDBC API calls instead of trying to use
> Oracle's proprietary APIs. You may have to use Oracle's connection
> pooling instead of Tomcat's.
>
> - -chris
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkjvXeIACgkQ9CaO5/Lv0PB2vQCfb8amv7/X/UPq6VBllTKh/awT
> CUIAnRTeS2VG3c6ExUUvagIn67tZPJLi
> =yyGE
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: dbcp error with java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.PoolingDataSource

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ziggy,

Ziggy wrote:
> The problem i am getting now is that i still cannot cast the class properly
> to get the underlying connection.

Your best bet is to use standard JDBC API calls instead of trying to use
Oracle's proprietary APIs. You may have to use Oracle's connection
pooling instead of Tomcat's.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkjvXeIACgkQ9CaO5/Lv0PB2vQCfb8amv7/X/UPq6VBllTKh/awT
CUIAnRTeS2VG3c6ExUUvagIn67tZPJLi
=yyGE
-----END PGP SIGNATURE-----

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


Re: dbcp error with java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.PoolingDataSource

Posted by Ziggy <zi...@gmail.com>.
Hi,

I had a look at the tomcat dbcp documentation and found that it is possible
to retrieve the underlying connection.

As described here http://commons.apache.org/dbcp/configuration.html

The problem i am getting now is that i still cannot cast the class properly
to get the underlying connection.

As described in the docs i added the following property in the datasource
definition

[code]
accessToUnderlyingConnectionAllowed="true"
[/code]

My datasource definition now looks like this

[code]
<Resource name="jdbc/testdb" auth="Container"
              type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
              url="jdbc:oracle:thin:@10.10.10.10:1521:testdb"
              username="testuser" password="testuser" maxActive="20"
maxIdle="10"
              maxWait="-1" accessToUnderlyingConnectionAllowed="true"/>
[/code]

And change my code slightly to be

[code]
Connection conn = ds.getConnection()
Connection dconn = ((DelegatingConnection) conn).getInnermostDelegate();
[/code]

The problem i have now is i am getting a class cast execption on the second
line (where i am trying to getInnermostDelegate().

Here is the error i am getting

[code]
java.lang.ClassCastException:
org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper
    at
com.bt.ccs21.data.accessors.ConsignmentDAO.submitDeclaration(ConsignmentDAO.java:250)
    at
com.bt.ccs21.presentation.events.consignment.search.SubmitDeclaration.midAction(SubmitDeclaration.java:105)
    at
com.bt.ccs21.presentation.events.CCS21EventAction.execute(CCS21EventAction.java:67)
    at
org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
    at
org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
    at
org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
    at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
    at
org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
    at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
    at
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
    at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
    at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
    at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
    at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
    at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
    at java.lang.Thread.run(Thread.java:595)

[/code]

Thanks

On Thu, Oct 9, 2008 at 5:53 PM, Ziggy <zi...@gmail.com> wrote:

> Hi,
>
> I originally only had it on $TOMCAT_HOME/common/lib but it didnt work.
> I only put it on both locations to test it out.
>
> I have now removed the copy from $APPLICATION_ROOT_DIR/WEB-INF/ lib/ and i
> still have the same problem described below.
>
> Thanks
>
>
> On Thu, Oct 9, 2008 at 5:35 PM, Caldarale, Charles R <
> Chuck.Caldarale@unisys.com> wrote:
>
>> > From: Ziggy [mailto:ziggy25@gmail.com]
>> > Sent: 2008 October 09, Thursday 11:12
>> > org.apache.tomcat.dbcp.dbcp.PoolingDataSource
>> >
>> > I have placed the jdbc driver on both the following directories
>> > [code]
>> > $TOMCAT_HOME/common/lib/
>> > $APPLICATION_ROOT_DIR/WEB-INF/lib/
>>
>> > [/code]
>>
>> Never, never, never put the same class(es) in more than one location in a
>> given branch of the classloader tree.
>>
>> Since you're using Tomcat to manage the DB connection pool, the .jar file
>> containing the JDBC driver classes must be placed in common/lib.
>>
>>  - 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 start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>

Re: dbcp error with java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.PoolingDataSource

Posted by Ziggy <zi...@gmail.com>.
Hi,

I originally only had it on $TOMCAT_HOME/common/lib but it didnt work.
I only put it on both locations to test it out.

I have now removed the copy from $APPLICATION_ROOT_DIR/WEB-INF/lib/ and i
still have the same problem described below.

Thanks


On Thu, Oct 9, 2008 at 5:35 PM, Caldarale, Charles R <
Chuck.Caldarale@unisys.com> wrote:

> > From: Ziggy [mailto:ziggy25@gmail.com]
> > Sent: 2008 October 09, Thursday 11:12
> > org.apache.tomcat.dbcp.dbcp.PoolingDataSource
> >
> > I have placed the jdbc driver on both the following directories
> > [code]
> > $TOMCAT_HOME/common/lib/
> > $APPLICATION_ROOT_DIR/WEB-INF/lib/
>
> > [/code]
>
> Never, never, never put the same class(es) in more than one location in a
> given branch of the classloader tree.
>
> Since you're using Tomcat to manage the DB connection pool, the .jar file
> containing the JDBC driver classes must be placed in common/lib.
>
>  - 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 start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>