Error An attempt by a client to checkout a Connection has timed out.

7,100 views
Skip to first unread message

Brad Luo

unread,
Mar 8, 2010, 4:45:28 AM3/8/10
to play-framework
Hi, All

When I develop with Play, it always throw the following exception, can
anyone tell me how to resolve it?

@61ml13e2e
Internal Server Error (500) for request GET /edit/district?
city=sh&page=17

Oops: PersistenceException
An unexpected error occured caused by exception PersistenceException:
org.hibern
ate.exception.GenericJDBCException: Cannot open connection

play.exceptions.UnexpectedException: Unexpected Error
at play.Invoker$Invocation.onException(Invoker.java:142)
at play.Invoker$Invocation.run(Invoker.java:182)
at Invocation.HTTP Request(Play!)
Caused by: javax.persistence.PersistenceException:
org.hibernate.exception.Gener
icJDBCException: Cannot open connection
at
org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException
(AbstractEntityManagerImpl.java:614)
at
org.hibernate.ejb.TransactionImpl.begin(TransactionImpl.java:41)
at play.db.jpa.JPAPlugin.startTx(JPAPlugin.java:227)
at play.db.jpa.JPAPlugin.beforeInvocation(JPAPlugin.java:190)
at play.Invoker$Invocation.before(Invoker.java:114)
at play.Invoker$Invocation.run(Invoker.java:175)
... 1 more
Caused by: org.hibernate.exception.GenericJDBCException: Cannot open
connection
at
org.hibernate.exception.SQLStateConverter.handledNonSpecificException
(SQLStateConverter.java:126)
at
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.j
ava:114)
at
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelp
er.java:66)
at
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelp
er.java:52)
at
org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager
.java:449)
at
org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.
java:167)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:
142)
at
org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:
85)
at
org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1354
)
at
org.hibernate.ejb.TransactionImpl.begin(TransactionImpl.java:38)
... 5 more
Caused by: java.sql.SQLException: An attempt by a client to checkout a
Connectio
n has timed out.
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:
106)
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:
65)
at
com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConne
ction(C3P0PooledConnectionPool.java:527)
at
com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(A
bstractPoolBackedDataSource.java:128)
at
org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.get
Connection(InjectedDataSourceConnectionProvider.java:46)
at
org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager
.java:446)
... 10 more
Caused by: com.mchange.v2.resourcepool.TimeoutException: A client
timed out whil
e waiting to acquire a resource from
com.mchange.v2.resourcepool.BasicResourcePo
ol@df672a -- timeout at awaitAvailable()
at
com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicRes
ourcePool.java:1317)
at
com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(
BasicResourcePool.java:557)
at
com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicR
esourcePool.java:477)
at
com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConne
ction(C3P0PooledConnectionPool.java:525)
... 13 more

Guillaume Bort

unread,
Mar 8, 2010, 12:55:22 PM3/8/10
to play-fr...@googlegroups.com
What is your database server? Perhaps you need to allow more
connections or configure the play datasource pool accordingly.

> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>
>

Brad Luo

unread,
Mar 10, 2010, 8:58:38 PM3/10/10
to play-framework
I set the db.pool.maxSize=100, the error is same.

Actually, I tested the jdbc pool that, I refreshed one page quickly,
the jdbc connnection increased quickly. When I stopped refreshing, the
jdbc connnection is still alive.

Brad Luo

unread,
Mar 10, 2010, 10:15:44 PM3/10/10
to play-framework
I set the db.pool.maxSize=30, and try to refresh the page quickly, the
error occurred.

Guillaume Bort

unread,
Mar 11, 2010, 3:02:33 AM3/11/10
to play-fr...@googlegroups.com
You need to check "on your database server" the max number of
connection allowed. Modifying db.pool.maxSize will change nothing.

2010/3/11 Brad Luo <luoti...@gmail.com>:

Prismpanda

unread,
May 2, 2010, 10:22:36 AM5/2/10
to play-framework
Hi there,

i ran into the same problem these days while doing operations on the
database.
I tested it with a normal page, which creates an Object at every
request an stores it into the DB. Every request results into an
additional database connection. When the specified pool limit in
application.conf is reached, the mentioned exception occurs and the
page is no longer accessible since every time the exception pops up.
The db server definitely allows more connections (in fact they are not
limited) and increasing the max pool size in the application.conf just
opens more connections till the given limit is reached. I just can
guess, that the connections are not given back so every request has to
obtain a new connection, but I can't figure out why. The error occurs
in MySQL Database as well as in the in-memory DB.

HTML code (test.html):
#{extends 'main.html' /} #{set title:'Home' /}

#{form @Application.save()}
<input name="cell.id" value="${cell?.id}" /><br />
<input name="cell.label" value="${cell?.label}" /><br />
<input name="cell.value" value="${cell?.value}" /><br />
<input type="submit" value="${cell ? 'save' : 'new'}" />
#{/form}

Serverside (Application class):
public static void test(Long id) {
Cell cell = null;
if (id != null) {
cell = Cell.findById(id);
}
render(cell);
}

public static void save(Cell cell) {
cell.save();
test(cell.getId());
}

Model:
public class Cell extends Model {

public String label;
public String value;

public Cell(String label, String value) {
super();
this.label = label;
this.value = value;
}
}

Hope anybody can help...

On 11 Mrz., 10:02, Guillaume Bort <guillaume.b...@gmail.com> wrote:
> You need to check "on your database server" the max number of
> connection allowed. Modifying db.pool.maxSize will change nothing.
>
> 2010/3/11 Brad Luo <luotian...@gmail.com>:
>
> > I set the db.pool.maxSize=30, and try to refresh the page quickly, the
> > error occurred.
>
> > On 3月11日, 上午9时58分, Brad Luo <luotian...@gmail.com> wrote:
> >> I set the db.pool.maxSize=100, the error is same.
>
> >> Actually, I tested the jdbcpoolthat, I refreshed one page quickly,

Prismpanda

unread,
May 2, 2010, 11:54:42 AM5/2/10
to play-framework
Okay, the problem only occurs, when starting the the webapp out of
eclipse (using the generated launch script by the eclipsify command).
Starting from the command line (play run ....) behaves like expected
with only one used connection which means, the connection is given
back.
Any ideas on that?

Guillaume Bort

unread,
May 2, 2010, 4:50:24 PM5/2/10
to play-fr...@googlegroups.com
Can you activate TRACE level for logs and check that the DBPlugin is
not started twice (in fact it is probably the case). It must be a
classpath problem.

Prismpanda

unread,
May 2, 2010, 10:41:26 PM5/2/10
to play-framework
That's it, any Plugin was loaded twice. I updated to 1.0.2.1 and then
had two Play directories but didn't correct the classpath properly so
he loaded the .jars from both directories. Using eclipsify again (as
it should probably have done before) solved the problem.
Thanks a lot!

On 2 Mai, 22:50, Guillaume Bort <guillaume.b...@gmail.com> wrote:
> Can you activate TRACE level for logs and check that the DBPlugin is
> not started twice (in fact it is probably the case). It must be a
> classpath problem.
>
> ...
>
> Erfahren Sie mehr >>
Reply all
Reply to author
Forward
0 new messages