Uploaded image for project: 'CDI TCK'
  1. CDI TCK
  2. CDITCK-80

Issue surrounding Bean.destroy() behavior

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 1.0.1.CR1, 1.1.0.Alpha1
    • 1.0.0.GA
    • Tests
    • None
    • jdk6 u15, glassfish v3

    Description

      org.jboss.jsr299.tck.tests.implementation.simple.resource.persistenceContext.PersistenceContextDesctructionTest seems to be invalid or jsr299 7.3.6 needs to clarify. Read below:

      Sec 7.3.6 Lifecycle of resources of JSR299 layout this asseertion:

      "When the create() method of a Bean object that represents a resource is called, the container creates and returns a con- tainer-specific internal reference to the Java EE component environment resource, entity manager, entity manager factory, remote EJB instance or web service reference. This reference is not directly exposed to the application.
      Before injecting or returning a contextual instance to the application, the container transforms its internal reference into an object that implements the bean types expected by the application and delegates method invocations to the underlying re- source, entity manager, entity manager factory, remote EJB instance or web service reference. This object must be passiva- tion capable.

      When the destroy() method is called, the container discards this internal reference and performs any cleanup required of state associated with the client or transaction."

      And there is this TCK test org.jboss.jsr299.tck.tests.implementation.simple.resource.persistenceContext.PersistenceContextDesctructionTest which does the following :

      CreationalContext<ManagedBean> creationalContext = getCurrentManager().createCreationalContext(managedBean);
      ManagedBean instance = managedBean.create(creationalContext);
      EntityManager em = instance.getPersistenceContext();
      assert em.isOpen();
      ==>managedBean.destroy(instance, creationalContext);
      assert !em.isOpen();

      When I looked in to the debugger I see that managedBean.destroy() call results in to calling GlassFish injected EntityManagerWarpper.close() which correctly throws InvalidStateException. This is as per JPA spec where EntityManager.close() is supposed to thro IllegalStateException for container manager EntityManager. See http://java.sun.com/javaee/5/docs/api/javax/persistence/EntityManager.html#close().

      Attachments

        Activity

          People

            pmuiratbleepbleep Pete Muir (Inactive)
            vivekp_jira Vive Pandey (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              PagerDuty