c3p0 and Acquisition Attempt Failed!!!

Posted on 12/06/2009 by Charalampos Chrysikopoulos

There was a GWT application that used c3p0 as a connection pool manager. This application had two connections for two different databases, one for the authentication and the other for the data retrieval.

Starting the application the user had to fill the login form and wait for the authorization. This action didn't use the c3p0. Then in the next step the application showed up 3 dropdown, each populated with its own query. Those 3 queries got the connection throw a datastore which used the c3p0 to serve connections.

So, after the authendication, many exceptions showed up in the console, many failures from the c3p0, like this:
WARN [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2] com.mchange.v2.resourcepool.BasicResourcePool (1841) - com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@425eb9 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (3). Last acquisition attempt exception:
java.sql.SQLException: An SQLException was provoked by the following failure: com.mchange.v2.resourcepool.ResourcePoolException: Attempted to use a closed or broken resource pool
Those exceptions showed up more than once. After some search in the internet I couldn't find a unique solution, everyone seems to have found his own way to solve the problem. And so did I.

The problem was those 3 drop downs after the loggin procedure. This 3 queries required 3 connections, one for each. At this time, the datasource was null and because the server calls in GWT are asynchronous, for every call was the datasource null... So, there was a tripple c3p0 initialization and this created the problems.

This entry was posted in c3p0, gwt and tagged by Charalampos Chrysikopoulos