Announcement Announcement Module
No announcement yet.
Database connections not being closed Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Database connections not being closed


    Spring 3.1.1
    Web Flow 2.3.0
    Hibernate 4.1.0


    When I make any calls to the EntityManager in a Spring Web Flow the connections are never closed. I've turned on c3p0 logging and it shows that the pool grows every time I start a flow. This is a real problem as the pool is exhausted and the application hangs. Reaching the end-state doesn't release the connections. I have service calls within the flow that use the EntityManager and c3p0's debug traces indicate these are the culprits. I've tried calling close on the EntityManager after completing the queries, but this has no effect. I have several standard Spring Controllers in my application as well; they make use of the EntityManager through the same service calls and the connections are closed. Only the flows are keeping the connections open. I'm using <persistence-context/> in the flows and my EntityManager is annotated with @PersistenceContext.

    I can post my configuration if that would help.

    Thanks in advance to anyone who has any ideas why only the flows are not closing connections.


    After doing some tests, I have determined that it has to do with the <persistence-context/>. I made a very simple flow that invokes a service to retrieve an object from the database <on-entry> and the <view-state> simply shows a JSP that says "Hello World" and doesn't make use of the flow-scoped object. When <persistence-context/> and the service call in <on-entry> are present, connections leak (3 every time). If I remove either one of those the connections are closed fine. Clearly there is a problem with the <persistence-context/> and any service calls that use the @PersistenceContext annotated EntityManager.
    Last edited by SSJ2Joseph; Feb 23rd, 2012, 12:44 PM. Reason: Update

  • #2

    I'm having exactly the same symptoms that you describe. Did you already found some anwsers about this issue?

    My Environment:

    Spring 3.1.2
    Web Flow 2.3.1
    Hibernate 4.1.6

    Best Regards