1. glassfish
  2. GLASSFISH-16712

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


    • 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:
    • Environment:

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


      Reference original forum thread here:

      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(
      at org.hibernate.impl.SessionFactoryImpl.close(
      at org.hibernate.ejb.EntityManagerFactoryImpl.close(
      at org.glassfish.persistence.jpa.JPADeployer.closeEMFs(
      at org.glassfish.persistence.jpa.JPADeployer.event(
      at org.glassfish.kernel.event.EventsImpl$
      at java.util.concurrent.Executors$
      at java.util.concurrent.FutureTask$Sync.innerRun(
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(
      at java.util.concurrent.ThreadPoolExecutor$
      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(
      at org.glassfish.web.loader.WebappClassLoader.loadClass(
      at org.hibernate.event.EventListeners.destroyListeners(
      ... 11 more


        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 ]


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


            • Created: