[2.0.4-java] Time out waiting for a free available connection

123 views
Skip to first unread message

jcstritt

unread,
Nov 5, 2012, 10:19:18 AM11/5/12
to play-fr...@googlegroups.com
Hi. I use Play 2.0.4 with Java and JPA for ORM. I have a "doLogin" method in Application controller. But after 5 calls (with db.default.partitionCount=1, db.default.maxConnectionsPerPartition=5
db.default.minConnectionsPerPartition=5), i have the message "Time out waiting for a free available connection". It seems dans JPA.em() (and the db connection) is not closed after each request, but a new one start on each. What can I do with this code :
  @Transactional(readOnly=true)
  public static Result doLogin(String name, String psw) {
    Result httpResult;
    try {
      // we delegate JPA operations on a subclass
      wrk = new WorkerDb(JPA.em());
      User user = wrk.loadUser(name, psw);
      if (user != null) {
        httpResult = ok("Ok");
      } else {
        httpResult = badRequest(name + " unknow or bad psw !");
        logout()
      }
    } catch (Exception e) {
      httpResult = badRequest("DB problem: " + e.getMessage());
      logout();
    }
    return httpResult;
  }

The error message :
[error] o.h.u.JDBCExceptionReporter - Timed out waiting for a free available connection.

Thank's for your help.

jcstritt

unread,
Nov 5, 2012, 11:17:06 AM11/5/12
to play-fr...@googlegroups.com
I have the answer : if i add 
 } finally {
      JPA.em().getTransaction().commit();
 }
All works finally fine.
Reply all
Reply to author
Forward
0 new messages