glassfish
  1. glassfish
  2. GLASSFISH-16712

Classloading issue when accessing class for the first time during JPA shutdown

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.1
    • Fix Version/s: 3.1.2_b11, 4.0
    • Component/s: deployment
    • Labels:
      None
    • Environment:

      Windows 7 Professional 64-bit, JDK 1.6.0 u24, Glassfish 3.1 b43

      Description

      Reference original forum thread here: http://www.java.net/forum/topic/glassfish/glassfish/classloading-issue-when-accessing-class-first-time-during-jpa-shutdown-glassfish-31

      To recap, Hibernate (and Ehcache) have relatively complex shutdown routines that sometimes result in the accessing of classes that have not yet been loaded. However, the class loader for the application is already stopped by the time these routines are called, which causes an IllegalStateException to be thrown.

      A test case is attached (a stripped down version of the one in the forum thread). Deploying and undeploying yields this stack trace (note that the following JVM flag needs to be added to the domain configuration to avoid an NPE caused by logging in the shutdown routine: -Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false):

      org.hibernate.HibernateException: could not destruct listeners
      at org.hibernate.event.EventListeners.destroyListeners(EventListeners.java:226)
      at org.hibernate.impl.SessionFactoryImpl.close(SessionFactoryImpl.java:972)
      at org.hibernate.ejb.EntityManagerFactoryImpl.close(EntityManagerFactoryImpl.java:127)
      at org.glassfish.persistence.jpa.JPADeployer.closeEMFs(JPADeployer.java:404)
      at org.glassfish.persistence.jpa.JPADeployer.event(JPADeployer.java:395)
      at org.glassfish.kernel.event.EventsImpl$1.run(EventsImpl.java:120)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
      at java.util.concurrent.FutureTask.run(FutureTask.java:138)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:662)
      Caused by: java.lang.IllegalStateException: WEB9031: WebappClassLoader unable to load resource [org.hibernate.event.EventListeners$2], because it has not yet been started, or was already stopped
      at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1410)
      at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1368)
      at org.hibernate.event.EventListeners.destroyListeners(EventListeners.java:215)
      ... 11 more

        Activity

        atomicknight created issue -
        Hong Zhang made changes -
        Field Original Value New Value
        Fix Version/s 3.2 [ 10969 ]
        Tags 3_1_1-scrubbed
        Nazrul made changes -
        Tags 3_1_1-scrubbed 3_1_1-review 3_1_1-scrubbed
        scatari made changes -
        Tags 3_1_1-review 3_1_1-scrubbed 3_1_1-scrubbed
        scatari made changes -
        Tags 3_1_1-scrubbed 3_1-next 3_1_1-scrubbed
        scatari made changes -
        Tags 3_1-next 3_1_1-scrubbed 3_1-next 3_1_1-scrubbed 3_1_2-review
        Hong Zhang made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 3.1.2_b11 [ 15325 ]
        Fix Version/s 4.0 [ 10970 ]
        Fix Version/s 3.2 [ 10969 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Hong Zhang
            Reporter:
            atomicknight
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: