commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: DBCP exception; very hard to debug
Date Mon, 28 Apr 2003 16:05:06 GMT

On Mon, 28 Apr 2003, Charles So wrote:

> Date: Mon, 28 Apr 2003 13:35:07 +0800
> From: Charles So <>
> Reply-To: Jakarta Commons Users List <>
> To:,
> Subject: DBCP exception; very hard to debug
> Hello,
> I am using DBCP 1.0 with Tomcat 4.1.24. The other Apache Commons I am
> using with DBCP1.0 are:
> commons-collections2.1.jar
> commons-logging-api.103.jar
> commons-pool.101.jar
> The webapp I am writing is set to have a maximum of 40 sessions. The
> allowed maximum number of connection to MySQL is 210. The minimum
> number of idle connection is set to 100 at Tomcat level.
> Each session uses 5 connections to start doing its work.

This is not a very good design for using connection pools (you should
design your apps so that they do not keep connections allocated in between
requests), but that is not the fundamental problem here.

> The first time I stress my webapp all is fine. I can see 40 sessions
> all used up in Tomcat's Manager.
> I then wait until all sessions to time out and stress it again. This
> time it is usually OK too.
> However, the 3rd time it is very likely to have thrown *tons* of this
> exception:
> DBCP borrowObject failed: java.sql.SQLException: Server connection
> failure during transaction.
> Attemtped reconnect 3 times. Giving up.
> Exception in Item org.apache.commons.dbcp.DbcpException:
> java.sql.SQLException: Server connection failure during transaction.
> Attemtped reconnect 3 times. Giving up.
> It seems that some objects are not released by DBCP. All 100
> connections shown in MySQL are idle.

The most likely cause for this is that the app neglects to return
connections to DBCP (often because an SQLException causes your code to
skip the release path).  This is not DBCP's problem.

> I tried using the nightly snapshot of DBCP, with all the above other
> commons. It is even worse. The webapp cannot even run the first time!
> It would complain:
> org.apache.jasper.JasperException:
> org.apache.commons.pool.impl.GenericObjectPool: method ()V not found

That means you've got an old version of commons-pool.jar or
commons-dbcp.jar around someplace, or you've got them installed in more
than one place in the class loader hierarchy.

It could also mean you didn't upgrade to the latest nightly build of
commons-pool (which the latest nightly build of commons-dbcp needs).

>          at
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.ja
> va:254)

Accessing databases directly from a JSP page too ... sheesh :-).


View raw message