Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-62006

Getting java.lang.ClassNotFoundException: javax.servlet.ServletException while running hudson.util.ProcessTree.get()

    • Jenkins 2.285, 2.277.2 released Apr 7, 2021

      When running Kubernetes agents, upon shutting them down (not sure how that is related), I sometimes get the following stacktrace

       

      AVERTISSEMENT: failed to shut down 1c62c2d9-920c-479c-94fe-9292dea21a67
      java.io.IOException: Remote call on JNLP4-connect connection from localhost/127.0.0.1:53049 failed
      	at hudson.remoting.Channel.call(Channel.java:1004)
      	at hudson.Launcher$RemoteLauncher.kill(Launcher.java:1083)
      	at org.jenkinsci.plugins.workflow.support.steps.ExecutorStepExecution$PlaceholderTask$2.run(ExecutorStepExecution.java:740)
      	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
      	at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266)
      	at java.util.concurrent.FutureTask.run(FutureTask.java)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletException
      	at hudson.util.ProcessTree.get(ProcessTree.java:432)
      	at hudson.Launcher$RemoteLauncher$KillTask.call(Launcher.java:1100)
      	at hudson.Launcher$RemoteLauncher$KillTask.call(Launcher.java:1091)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:211)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:54)
      	at hudson.remoting.Request$2.run(Request.java:369)
      	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:117)
      	... 1 more
      	Suppressed: hudson.remoting.Channel$CallSiteStackTrace: Remote call to JNLP4-connect connection from localhost/127.0.0.1:53049
      		at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1788)
      		at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356)
      		at hudson.remoting.Channel.call(Channel.java:998)
      		at hudson.Launcher$RemoteLauncher.kill(Launcher.java:1083)
      		at org.jenkinsci.plugins.workflow.support.steps.ExecutorStepExecution$PlaceholderTask$2.run(ExecutorStepExecution.java:740)
      		at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
      		at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
      		at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      		at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266)
      		at java.util.concurrent.FutureTask.run(FutureTask.java)
      		at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      		at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      		... 1 more
      Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletException
      	at hudson.remoting.RemoteClassLoader$ClassLoaderProxy.fetch(RemoteClassLoader.java:811)
      	at sun.reflect.GeneratedMethodAccessor126.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:931)
      	at hudson.remoting.Request$2.run(Request.java:369)
      	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
      	at org.jenkinsci.remoting.CallableDecorator.call(CallableDecorator.java:18)
      	at hudson.remoting.CallableDecoratorList$1.call(CallableDecoratorList.java:21)
      	at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
      	at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:71)
      	at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266)
      	at java.util.concurrent.FutureTask.run(FutureTask.java)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	... 1 more
      	Suppressed: hudson.remoting.Channel$CallSiteStackTrace: Remote call to JNLP4-connect connection to host.docker.internal/192.168.65.2:52872
      		at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1737)
      		at hudson.remoting.Request.call(Request.java:202)
      		at hudson.remoting.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:288)
      		at com.sun.proxy.$Proxy5.fetch(Unknown Source)
      		at hudson.remoting.RemoteClassLoader.findClass(RemoteClassLoader.java:317)
      		at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
      		at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
      		at hudson.util.ProcessTree.get(ProcessTree.java:432)
      		at hudson.Launcher$RemoteLauncher$KillTask.call(Launcher.java:1100)
      		at hudson.Launcher$RemoteLauncher$KillTask.call(Launcher.java:1091)
      		at hudson.remoting.UserRequest.perform(UserRequest.java:211)
      		at hudson.remoting.UserRequest.perform(UserRequest.java:54)
      		at hudson.remoting.Request$2.run(Request.java:369)
      		at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
      		at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      		at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      		at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      		at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:117)
      		... 1 more 

      My interpretation is that loading SlaveComputer on the agent JVM causes ServletException to be pulled (because it is in the signature of several methods of Computer).

      I believe moving the method over to a separate utility class without ties to ServletException would prevent this problem to occur.

          [JENKINS-62006] Getting java.lang.ClassNotFoundException: javax.servlet.ServletException while running hudson.util.ProcessTree.get()

          Vincent Latombe created issue -
          Vincent Latombe made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Vincent Latombe made changes -
          Remote Link New: This issue links to "PR #4681 (Web Link)" [ 24863 ]
          Vincent Latombe made changes -
          Status Original: In Progress [ 3 ] New: In Review [ 10005 ]
          Daniel Beck made changes -
          Released As New: Jenkins 2.235
          Resolution New: Fixed [ 1 ]
          Status Original: In Review [ 10005 ] New: Closed [ 6 ]

          Tim Jacomb added a comment -

          I seem to be getting this in the slack plugin when using a freestyle build over remoting for some reason.

          before this change:

          Caused: java.lang.NoClassDefFoundError: javax/servlet/ServletException
          	at hudson.util.ProcessTree.get(ProcessTree.java:432)
          	at hudson.Launcher$RemoteLauncher$KillTask.call(Launcher.java:1100)
          	at hudson.Launcher$RemoteLauncher$KillTask.call(Launcher.java:1091)
          	at hudson.remoting.UserRequest.perform(UserRequest.java:211)
          	at hudson.remoting.UserRequest.perform(UserRequest.java:54)
          	at hudson.remoting.Request$2.run(Request.java:369)
          	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
          	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
          	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
          	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
          	at java.lang.Thread.run(Thread.java:748)
          

          After the change the stacktrace just moves down a line:

          Caused: java.lang.NoClassDefFoundError: javax/servlet/ServletException
          	at jenkins.agents.AgentComputerUtil.getChannelToMaster(AgentComputerUtil.java:48)
          	at hudson.util.ProcessTree.get(ProcessTree.java:432)
          	at hudson.Launcher$RemoteLauncher$KillTask.call(Launcher.java:1100)
          	at hudson.Launcher$RemoteLauncher$KillTask.call(Launcher.java:1091)
          	at hudson.remoting.UserRequest.perform(UserRequest.java:211)
          	at hudson.remoting.UserRequest.perform(UserRequest.java:54)
          	at hudson.remoting.Request$2.run(Request.java:369)
          	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
          	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
          	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
          	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
          	at java.lang.Thread.run(Thread.java:748)
          

          Tim Jacomb added a comment - I seem to be getting this in the slack plugin when using a freestyle build over remoting for some reason. before this change: Caused: java.lang.NoClassDefFoundError: javax/servlet/ServletException at hudson.util.ProcessTree.get(ProcessTree.java:432) at hudson.Launcher$RemoteLauncher$KillTask.call(Launcher.java:1100) at hudson.Launcher$RemoteLauncher$KillTask.call(Launcher.java:1091) at hudson.remoting.UserRequest.perform(UserRequest.java:211) at hudson.remoting.UserRequest.perform(UserRequest.java:54) at hudson.remoting.Request$2.run(Request.java:369) at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang. Thread .run( Thread .java:748) After the change the stacktrace just moves down a line: Caused: java.lang.NoClassDefFoundError: javax/servlet/ServletException at jenkins.agents.AgentComputerUtil.getChannelToMaster(AgentComputerUtil.java:48) at hudson.util.ProcessTree.get(ProcessTree.java:432) at hudson.Launcher$RemoteLauncher$KillTask.call(Launcher.java:1100) at hudson.Launcher$RemoteLauncher$KillTask.call(Launcher.java:1091) at hudson.remoting.UserRequest.perform(UserRequest.java:211) at hudson.remoting.UserRequest.perform(UserRequest.java:54) at hudson.remoting.Request$2.run(Request.java:369) at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang. Thread .run( Thread .java:748)
          Tim Jacomb made changes -
          Assignee Original: Vincent Latombe [ vlatombe ]
          Resolution Original: Fixed [ 1 ]
          Status Original: Closed [ 6 ] New: Reopened [ 4 ]
          Tim Jacomb made changes -
          Status Original: Reopened [ 4 ] New: Open [ 1 ]
          Tim Jacomb made changes -
          Component/s New: azure-container-agents-plugin [ 23149 ]
          Component/s New: digitalocean-plugin [ 18831 ]
          Component/s New: slack-plugin [ 18321 ]

          Tim Jacomb added a comment -

          This can be easily reproduced in:

          • slack plugin - use a freestyle build and slackUploadFile on an agent
          • digitalocean-plugin - https://groups.google.com/g/jenkinsci-dev/c/kZ-3kEblquc/m/vsVbCXcgAAAJ
          • azure-container-agents-plugin - freestyle build on an ACI agent, or tail the logs of the agent in a pipeline build you will see that this issue is still logged but it doesn't make it to the pipeline build and doesn't fail the build

          Tim Jacomb added a comment - This can be easily reproduced in: slack plugin - use a freestyle build and slackUploadFile on an agent digitalocean-plugin - https://groups.google.com/g/jenkinsci-dev/c/kZ-3kEblquc/m/vsVbCXcgAAAJ azure-container-agents-plugin - freestyle build on an ACI agent, or tail the logs of the agent in a pipeline build you will see that this issue is still logged but it doesn't make it to the pipeline build and doesn't fail the build

            Unassigned Unassigned
            vlatombe Vincent Latombe
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: