Play Framework 2.2 : Error: This exception has been logged with id

谁都会走 提交于 2019-12-25 07:58:50

问题


I am completed building a website in Play framework. The website is deployed at server. But, I am facing some random occurring issue like this one..

This exception has been logged with id 6ilmmm0fk. 

I got the same error previously as well. So, I restarted the complete application and it was gone. But, again I am facing the same error.

Why is this error occurring?

I got the stack trace that looks like this

play.api.Application$$anon$1: Execution exception[[SQLException: Timed out waiting for a free available connection.]]
        at play.api.Application$class.handleError(Application.scala:293) ~[com.typesafe.play.play_2.10-2.2.2.jar:2.2.2]
        at play.api.DefaultApplication.handleError(Application.scala:399) [com.typesafe.play.play_2.10-2.2.2.jar:2.2.2]
        at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$2$$anonfun$applyOrElse$3.apply(PlayDefaultUpstreamHandler.scala:261) [com.typesafe.play.play_2.10-2.2.2.jar:2.2.2]
        at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$2$$anonfun$applyOrElse$3.apply(PlayDefaultUpstreamHandler.scala:261) [com.typesafe.play.play_2.10-2.2.2.jar:2.2.2]        at scala.Option.map(Option.scala:145) [org.scala-lang.scala-library-2.10.3.jar:na]
        at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$2.applyOrElse(PlayDefaultUpstreamHandler.scala:261) [com.typesafe.play.play_2.10-2.2.2.jar:2.2.2]
Caused by: java.sql.SQLException: Timed out waiting for a free available connection.
        at com.jolbox.bonecp.DefaultConnectionStrategy.getConnectionInternal(DefaultConnectionStrategy.java:88) ~[com.jolbox.bonecp-0.8.0.RELEASE.jar:na]
        at com.jolbox.bonecp.AbstractConnectionStrategy.getConnection(AbstractConnectionStrategy.java:90) ~[com.jolbox.bonecp-0.8.0.RELEASE.jar:na]
        at com.jolbox.bonecp.BoneCP.getConnection(BoneCP.java:553) ~[com.jolbox.bonecp-0.8.0.RELEASE.jar:na]
        at com.jolbox.bonecp.BoneCPDataSource.getConnection(BoneCPDataSource.java:131) ~[com.jolbox.bonecp-0.8.0.RELEASE.jar:na]
        at play.api.db.DBApi$class.getConnection(DB.scala:67) ~[com.typesafe.play.play-jdbc_2.10-2.2.2.jar:2.2.2]
        at play.api.db.BoneCPApi.getConnection(DB.scala:276) ~[com.typesafe.play.play-jdbc_2.10-2.2.2.jar:2.2.2][^[[31merror^[[0m] play - Cannot invoke the action, eventually got an error: java.sql.SQLException: Timed out waiting for a free available connection.
[^[[31merror^[[0m] application

the stack trace shows Timed Out for SQL query may be I am having too many open connections in database.

UPDATE

I have found that database is leaking connections. Going through the code I have checked and updated the transactions as follows

try{
      Ebean.beginTransaction()
       // All code goes here
       //
      Ebean.commitTransaction()
}catch{
       e.printStackTrace();
}finally{
      Ebean.endTransaction();
}

Is there a better way to identify open connections and loop holes. Because I am still facing the above issue.

UPDATE

I have moved to HikariCP JDBC instead of Play frameworks BoneCP. There are issues with the way BoneCP handles connection closing.


回答1:


You might want to configure your jdbc pool to have longer timeouts on your connections. In your application.conf you could had: db.default.connectionTimeout=30 seconds

For more information: http://www.playframework.com/documentation/2.2.x/SettingsJDBC




回答2:


I didn't find the exact solution for the above problem but a work around. I switched to HikariCp for my DB connections, which did resolve the issue (its now working for 5months without and single exception or thread leak). I would suggest a switch to HikariCP if they are facing the above issues with BoneCP.



来源:https://stackoverflow.com/questions/24527954/play-framework-2-2-error-this-exception-has-been-logged-with-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!