我一直在使用Play 2.0.2来创建Java应用程序.几天我遇到了问题.在~100请求之后,服务器开始抛出此异常:
[[sqlException: Timed out waiting for a free available connection.]]
我用DB.getConnection()创建了一个新的Connection实例.我不关闭Connection实例,因为每个请求只有一个实例,据我所知,当活动TCP连接关闭时它会自动关闭Connection实例.
我试图将db.default.connectionTimeout值增加到100秒,但它无法解决问题.然后我检查了活动的Postgresql连接,并且没有活动连接.我也重新启动了Postgresql,但它也无法解决问题.
现在解决这个问题的唯一方法是杀死Play20实例并启动一个新实例.
这是Play2.0创建的日志:
! @6cg9il6ki - Internal server error,for request [GET [AN URL]] ->
play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception [[sqlException: Timed out waiting for a free available connection.]]
at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:134) [play_2.9.1.jar:2.0.2]
at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:115) [play_2.9.1.jar:2.0.2]
at akka.actor.Actor$class.apply(Actor.scala:318) [akka-actor.jar:2.0.2]
at play.core.ActionInvoker.apply(Invoker.scala:113) [play_2.9.1.jar:2.0.2]
at akka.actor.ActorCell.invoke(ActorCell.scala:626) [akka-actor.jar:2.0.2]
at akka.dispatch.MailBox.processMailBox(MailBox.scala:197) [akka-actor.jar:2.0.2]
Caused by: java.sql.sqlException: Timed out waiting for a free available connection.
at com.jolBox.bonecp.BoneCP.getConnection(BoneCP.java:503) ~[bonecp.jar:0.7.1.RELEASE]
at com.jolBox.bonecp.BoneCPDataSource.getConnection(BoneCPDataSource.java:114) ~[bonecp.jar:0.7.1.RELEASE]
at play.api.db.DBApi$class.getConnection(DB.scala:64) ~[play_2.9.1.jar:2.0.2]
at play.api.db.BoneCPApi.getConnection(DB.scala:273) ~[play_2.9.1.jar:2.0.2]
at play.api.db.DB$$anonfun$getConnection$1.apply(DB.scala:129) ~[play_2.9.1.jar:2.0.2]
at play.api.db.DB$$anonfun$getConnection$1.apply(DB.scala:129) ~[play_2.9.1.jar:2.0.2]
最佳答案