commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "cyrille.roy@free.fr" <cyrille....@free.fr>
Subject Re: DelegatingConnection and getInnerMostConnection() not working
Date Sat, 11 Oct 2008 14:19:33 GMT
Hi,

I also tried unsuccessfuly to access the underlying connection to 
physically close it using the
Connection = ds.getConnection();
Connection dconn = ((DelegatingConnection) conn).getInnermostDelegate();
dconn.close();

I managed to physically close a connection, but I wasn't able to 
recreate it after, and I destroyed the counter for number of max active 
sessions.
So, I think you will have the same issue once you have solved your 
ClassCastException.
see 
http://mail-archives.apache.org/mod_mbox/commons-user/200810.mbox/%3C48E5047D.3080707@free.fr%3E

I changed the approach by
- creating my own MyBasicDataSourceFactory extending BasicDataSourceFactory
- creating my own MyBasicDataSource extending BasicDataSource
- creating my own MyGenericPool extending GenericObjectPool
then overriding the returnObject method which will in some cases call 
the **invalidateObject** method.

hope this helps,
Cyrille.


Ziggy a écrit :
> Hi,
>
> I am trying to get to the underlying connection from the Tomcat pool but
> having some problems. I used this document to configure the pool
> http://commons.apache.org/dbcp/configuration.html
>
> The connection pool works fine if i dont try to get the underlying
> connection.
> I have the following configuration
>
> App server = Tomcat5.5
> jdbc driver = Type 4
>
> <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"/>
>
> And here is what i am trying to do (and where i get an exception)
>
> Connection = ds.getConnection();
> Connection dconn = ((DelegatingConnection) conn).getInnermostDelegate();
>
>
> When i try to get the underlying connection i get the following error
>
> Throwable:org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper
>
> java.lang.ClassCastException:
> org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper
>     at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:149)
>     at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:115)
>     at
> com.bt.ccs21.data.accessors.ConsignmentDAO.submitDeclaration(ConsignmentDAO.java:251)
>     at
> com.bt.ccs21.presentation.events.consignment.search.SubmitDeclaration.midAction(SubmitDeclaration.java:107)
>     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)
>
>
> I have the following libraries in $TOMCAT_HOME/common/lib
>
> - commons-dbcp-1.2.2.jar
> - oracle_jdbc14.jar
>
> I dont know why it is giving me this error. Any help will be greatly
> appreciated.
>
>   

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message