Question

I have a Play Framework 2.2.2 application that I am deploying as a .war file and running under Tomcat 7. My application runs for days without problems on my local dev machine (through Play's built in server, not Tomcat), but once I deploy it under Tomcat, after several hours the Tomcat server will lock up, taking down all the other applications running on it as well.

I think the problem is that the BoneCP connection pool in Play, and the built-in connection pool of Tomcat are conflicting. There isn't much or any useful information in the Tomcat logs, so I'm kind of left guessing here.

I'd like to disable the BoneCP connection pooling within my Play application, but cannot find any information on how to do so.

Any advice appreciated!

Was it helpful?

Solution

There are several possible solutions for this, which might be more or less preferrable for your deployment environment.

  1. Play gives you an "out-of-the-box" database connection, which you don't need to use. Drop the Play JDBC component from your build file (remove jdbc from your libraryDependencies) and setup your JDBC connections manually by yourself. For example, you can make a singleton TomcatConnectionPool that has a function getConnection() that gives you the JDBC connection you need for use in your Play actions.

  2. Write your own plugin specifically extending Play's DBPlugin interface so that it's a database plugin. Implement it like Play's BoneCPPlugin but make it use the Tomcat connection pool instead of BoneCP.

  3. Use someone else's already made custom Play Database Plugin, like this one that uses c3p0. I have some anecdotal evidence that c3p0 works well with Tomcat, but your mileage my vary.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top