JpaPersistService.end() doesn't call entityManager.remove() in finally block
From hristo.sabev on March 20, 2012 13:53:45
This is the JpaPersistService.end() method as copied from the source code:
public void end() { EntityManager em = entityManager.get();
// Let's not penalize users for calling end() multiple times. if (null == em) { return; }
em.close(); entityManager.remove(); }
The call to em.close() could fail sometimes. In my particular case it failed because I tried to save an object with byte[] field having more then 500 bytes. This coused the last line to be skipped. Effectively this thread could no longer be used to serve requests because the begin() method of JpaPersistService would always fail.
The fix is to simply surround the em.close() invocation with try-finally block
Original issue: http://code.google.com/p/google-guice/issues/detail?id=694
Source: google/guice