glassfish
  1. glassfish
  2. GLASSFISH-17468

WebappClassLoader leak after undeployment

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.1.2_b17, 4.0
    • Component/s: web_services
    • Labels:
      None

      Description

      If one use a deploy a war with annotation, access it and undeploy, then the WebappClassLoader is still in memory. This is because the "deployment-jar-scanner" thread is still referencing the WebappClassLoader as context class loader.

      I confirm that the issue is gone if I do the following:
      Index: src/main/java/com/sun/enterprise/v3/server/ApplicationLifecycle.java
      ===================================================================
      — src/main/java/com/sun/enterprise/v3/server/ApplicationLifecycle.java (revision 50397)
      +++ src/main/java/com/sun/enterprise/v3/server/ApplicationLifecycle.java (working copy)
      @@ -2166,6 +2166,7 @@
      Thread t = new Thread(r);
      t.setName("deployment-jar-scanner");
      t.setDaemon(true);
      + t.setContextClassLoader(null);
      return t;
      }
      });

      I also notice that the corresponding code in ApplicationLifecycle was invoked twice.
      First and second invocation has context classloader URLClassLoader and WebappClassLoader respectively.

      The stack traces are as follows:
      (1) at java.lang.Thread.dumpStack(Thread.java:1273)
      at com.sun.enterprise.v3.server.ApplicationLifecycle$4.newThread(ApplicationLifecycle.java:2169)
      at java.util.concurrent.ThreadPoolExecutor.addThread(ThreadPoolExecutor.java:672)
      at java.util.concurrent.ThreadPoolExecutor.addIfUnderCorePoolSize(ThreadPoolExecutor.java:697)
      at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:652)
      at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:92)
      at org.glassfish.hk2.classmodel.reflect.Parser.parse(Parser.java:296)
      at com.sun.enterprise.v3.server.ApplicationLifecycle.getDeployableTypes(ApplicationLifecycle.java:509)
      at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:351)
      at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
      at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:382)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1064)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1244)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1232)
      at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:459)
      at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:209)
      at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
      at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:238)
      at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
      at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
      at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
      at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
      at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
      at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
      at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
      at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
      at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
      at java.lang.Thread.run(Thread.java:680)

      (2) at java.lang.Thread.dumpStack(Thread.java:1273)
      at com.sun.enterprise.v3.server.ApplicationLifecycle$4.newThread(ApplicationLifecycle.java:2169)
      at java.util.concurrent.ThreadPoolExecutor.addThread(ThreadPoolExecutor.java:672)
      at java.util.concurrent.ThreadPoolExecutor.addIfUnderCorePoolSize(ThreadPoolExecutor.java:697)
      at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:652)
      at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:92)
      at org.glassfish.hk2.classmodel.reflect.Parser.parse(Parser.java:296)
      at org.glassfish.hk2.classmodel.reflect.Parser.parse(Parser.java:243)
      at com.sun.enterprise.deployment.annotation.impl.ModuleScanner.addScanDirectory(ModuleScanner.java:326)
      at com.sun.enterprise.deployment.annotation.impl.WarScanner.process(WarScanner.java:149)
      at com.sun.enterprise.deployment.annotation.impl.WarScanner.process(WarScanner.java:72)
      at com.sun.enterprise.deployment.archivist.Archivist.processAnnotations(Archivist.java:563)
      at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:445)
      at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:432)
      at com.sun.enterprise.deployment.archivist.Archivist.readRestDeploymentDescriptors(Archivist.java:408)
      at com.sun.enterprise.deployment.archivist.Archivist.openWith(Archivist.java:267)
      at com.sun.enterprise.deployment.archivist.ApplicationFactory.openWith(ApplicationFactory.java:240)
      at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:175)
      at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:94)
      at com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(ApplicationLifecycle.java:828)
      at com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:770)
      at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:368)
      at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
      at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:382)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1064)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1244)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1232)
      at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:459)
      at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:209)
      at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
      at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:238)
      at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
      at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
      at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
      at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
      at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
      at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
      at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
      at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
      at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
      at java.lang.Thread.run(Thread.java:680)

        Activity

        Hide
        Lukas Jungmann added a comment -

        corrected fixfor version

        Show
        Lukas Jungmann added a comment - corrected fixfor version
        Hide
        Lukas Jungmann added a comment -

        fixed in trunk/4.0 - revision 51881. Can I ask someone for verification, please? Thanks!

        Show
        Lukas Jungmann added a comment - fixed in trunk/4.0 - revision 51881. Can I ask someone for verification, please? Thanks!
        Hide
        Martin Grebac added a comment -

        Lukas, would you please attach the fix diff here and follow the GF process and request 3.1.2 fix integration? Thanks.

        Show
        Martin Grebac added a comment - Lukas, would you please attach the fix diff here and follow the GF process and request 3.1.2 fix integration? Thanks.
        Show
        Lukas Jungmann added a comment - fix diff: http://java.net/projects/glassfish/sources/svn/revision/51881 license header update: http://java.net/projects/glassfish/sources/svn/revision/51899
        Hide
        Lukas Jungmann added a comment - - edited

        fixed also in 3.1.2 branch:

        lukas@lucas-ubuntu:/space/sources/glassfish/3.1.2/webservices/jsr109-impl$ svn ci -m "GLASSFISH-17468: WebappClassLoader leak after undeployment"
        Sending jsr109-impl/src/main/java/org/glassfish/webservices/JAXWSServletModule.java
        Transmitting file data .
        Committed revision 51933.

        Show
        Lukas Jungmann added a comment - - edited fixed also in 3.1.2 branch: lukas@lucas-ubuntu:/space/sources/glassfish/3.1.2/webservices/jsr109-impl$ svn ci -m " GLASSFISH-17468 : WebappClassLoader leak after undeployment" Sending jsr109-impl/src/main/java/org/glassfish/webservices/JAXWSServletModule.java Transmitting file data . Committed revision 51933.

          People

          • Assignee:
            Lukas Jungmann
            Reporter:
            Shing Wai Chan
          • Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: