Uploaded image for project: 'CDI Specification Issues'
  1. CDI Specification Issues
  2. CDI-523

CDI spec tries to dispose a container-managed entity manager.

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved (View Workflow)
    • Major
    • Resolution: Done
    • 1.2.Final, 1.1.Final
    • 2.0 .Final
    • None
    • None

    Description

      Section "3.5.2. Declaring a disposer method" has this example:

      public class Resources {
      
          @PersistenceContext
          @Produces @UserDatabase
          private EntityManager em;
          
          public void close(@Disposes @UserDatabase EntityManager em) {
              em.close();
          }
      }
      

      The disposer method above call EntityManager.close() on a container-managed entity manager which result in an IllegalStateException being thrown and the entity manager remains open. This behavior is expected as the JPA specification forbids application code to close a container-managed entity manager. JPA 2.1, section "7.9.1 Container Responsibilities" says:

      The container must throw the IllegalStateException if the application calls EntityManager.close on a container-managed entity manager.

      This has been proved here and a theoretical walkthough surrounding entity managers combined with CDI scopes is available here.

      Attachments

        Activity

          People

            meetoblivion_jira John Ament (Inactive)
            martin.andersson_jira Martin Andersson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: