Uploaded image for project: 'Seam 2'
  1. Seam 2
  2. JBSEAM-2803

In specific cases, a closed entitymanager is injected by seam, resulting in illegalstateexceptions

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Rejected
    • Affects Version/s: 2.1.0.A1
    • Fix Version/s: None
    • Component/s: Framework
    • Labels:
      None
    • Environment:

      Glassfish v2ur1, Icefaces 1.7.0

    • Estimated Difficulty:
      Low

      Description

      EntityManager is put to event Scope for better memory usage and GC.
      Class that tries to use the entitymanager is itself in conversation scope, and this specific behavior occurs after icefaces file upload.
      Injected em is closed and throws IllegalStateException for every function used (as it should when it's closed).

      I dug around the persistence namespace/package and found once place that could explain it.

      src/main/org/jboss/seam/persistence/ManagedPersistenceContext.java
      line 225 to 229
      if (entityManager!=null)

      { entityManager.close(); }

      As seen, entityManager is closed but since getEntityManager() function only creates new entitymanager when entityMAnager is null and does not check for entityManager being closed, the closed entitymanager gets passed around.

      I added entityManager = null; after the entityManager.close(); line so that the getEntityManager() would correctly return new entitymanager after old one was closed and recompiled the latest sources.

      It seemed to fix this issue, no more errors, em injected to the conversation scope class is not closed one anymore
      There may be some other things related to this like JBSEAM-2666 but I'm not entirely sure about it.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                efbiaiinzinz Indrek Altpere
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 4 hours
                  4h
                  Remaining:
                  Remaining Estimate - 4 hours
                  4h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified