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

Setting ConsoleLogFilter implementation from library by withContext step results into "java.lang.IllegalArgumentException: Unable to locate class file for class" on slave node

    Details

    • Similar Issues:

      Description

      Note, ConsoleLogFilter is a simple proxy without any logic inside.
       
      vars/withLogFilter.groovy        # From library

      class LogFilter extends hudson.console.ConsoleLogFilter implements Serializable {
          @NonCPS
          java.io.OutputStream decorateLogger(Run build, java.io.OutputStream logger) throws IOException, InterruptedException { return logger }
          }
      }
      
      def call(Closure closure) {
        this.withContext(new LogFilter()) {
          closure.call()
        }
      } 

      Jenkinsfile

      library('demo')
      
      // node('master') { // Works! so it's not a duplicate of JENKINS-53151
      node('slave') {
        withLogFilter {
          sh "pwd"  // triggers serialization as using just 'echo' step works fine
          echo "foobar"
        }
      } 

      Results into the following error on slave node (on master works fine as class is resolved there, I suppose):

      java.lang.IllegalArgumentException: Unable to locate class file for class LogFilter

      Please find detailed stack trace here:

      Running on slave in /home/centos/workspace/pipeline
      [Pipeline] {
      [Pipeline] withContext
      [Pipeline] {
      [Pipeline] sh
      [Pipeline] }
      [Pipeline] // withContext
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      Also:   hudson.remoting.Channel$CallSiteStackTrace: Remote call to channel
      		at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1743)
      		at hudson.remoting.Request.call(Request.java:202)
      		at hudson.remoting.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:286)
      		at com.sun.proxy.$Proxy5.fetch3(Unknown Source)
      		at hudson.remoting.RemoteClassLoader.findClass(RemoteClassLoader.java:209)
      		at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      		at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      		at java.lang.Class.forName0(Native Method)
      		at java.lang.Class.forName(Class.java:348)
      		at hudson.remoting.MultiClassLoaderSerializer$Input.resolveClass(MultiClassLoaderSerializer.java:134)
      		at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1867)
      		at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1750)
      		at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2041)
      		at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1572)
      		at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2286)
      		at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2210)
      		at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2068)
      		at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1572)
      		at java.io.ObjectInputStream.readObject(ObjectInputStream.java:430)
      		at java.util.ArrayList.readObject(ArrayList.java:797)
      		at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
      		at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      		at java.lang.reflect.Method.invoke(Method.java:498)
      		at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1170)
      		at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2177)
      		at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2068)
      		at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1572)
      		at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2286)
      		at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2210)
      		at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2068)
      		at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1572)
      		at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2286)
      		at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2210)
      		at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2068)
      		at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1572)
      		at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2286)
      		at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2210)
      		at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2068)
      		at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1572)
      		at java.io.ObjectInputStream.readObject(ObjectInputStream.java:430)
      		at hudson.remoting.UserRequest.deserialize(UserRequest.java:291)
      		at hudson.remoting.UserRequest.perform(UserRequest.java:190)
      		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)
      java.lang.IllegalArgumentException: Unable to locate class file for class LogFilter
      	at hudson.remoting.Which.classFileUrl(Which.java:65)
      	at hudson.remoting.RemoteClassLoader$ClassLoaderProxy.fetch4(RemoteClassLoader.java:860)
      	at hudson.remoting.RemoteClassLoader$ClassLoaderProxy.fetch3(RemoteClassLoader.java:889)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	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:929)
      	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:19)
      	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)
      Also:   hudson.remoting.Channel$CallSiteStackTrace: Remote call to egp-pipeline-demo-atl1-tkostyuk
      		at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1743)
      		at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:357)
      		at hudson.remoting.Channel.call(Channel.java:957)
      		at hudson.Launcher$RemoteLauncher.launch(Launcher.java:1060)
      		at hudson.Launcher$ProcStarter.start(Launcher.java:455)
      		at org.jenkinsci.plugins.durabletask.BourneShellScript.launchWithCookie(BourneShellScript.java:206)
      		at org.jenkinsci.plugins.durabletask.FileMonitoringTask.launch(FileMonitoringTask.java:99)
      		at org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep$Execution.start(DurableTaskStep.java:308)
      		at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:268)
      		at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:176)
      		at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122)
      		at sun.reflect.GeneratedMethodAccessor59567.invoke(Unknown Source)
      		at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      		at java.lang.reflect.Method.invoke(Method.java:498)
      		at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      		at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      		at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
      		at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
      		at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
      		at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      		at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
      		at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:158)
      		at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
      		at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:157)
      		at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:156)
      		at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:160)
      		at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:130)
      		at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:130)
      		at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
      		at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:57)
      		at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)
      		at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82)
      		at sun.reflect.GeneratedMethodAccessor375.invoke(Unknown Source)
      		at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      		at java.lang.reflect.Method.invoke(Method.java:498)
      		at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
      		at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
      		at com.cloudbees.groovy.cps.Next.step(Next.java:83)
      		at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
      		at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
      		at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129)
      		at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
      		at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
      		at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
      		at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
      		at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:186)
      		at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:370)
      		at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:93)
      		at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:282)
      		at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:270)
      		at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
      		at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      		at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131)
      		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)
      Caused: java.lang.Error: Failed to deserialize the Callable object.
      	at hudson.remoting.UserRequest.perform(UserRequest.java:196)
      	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)
      Caused: java.io.IOException: Remote call on egp-pipeline-demo-atl1-tkostyuk failed
      	at hudson.remoting.Channel.call(Channel.java:963)
      	at hudson.Launcher$RemoteLauncher.launch(Launcher.java:1060)
      	at hudson.Launcher$ProcStarter.start(Launcher.java:455)
      	at org.jenkinsci.plugins.durabletask.BourneShellScript.launchWithCookie(BourneShellScript.java:206)
      	at org.jenkinsci.plugins.durabletask.FileMonitoringTask.launch(FileMonitoringTask.java:99)
      	at org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep$Execution.start(DurableTaskStep.java:308)
      	at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:268)
      	at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:176)
      	at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122)
      	at sun.reflect.GeneratedMethodAccessor59567.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
      	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:158)
      	at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:157)
      	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:156)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:160)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:130)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:130)
      	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
      	at WorkflowScript.run(WorkflowScript:9)
      	at withLogFilter.call(withLogFilter.groovy:14)
      	at ___cps.transform___(Native Method)
      	at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:57)
      	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)
      	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82)
      	at sun.reflect.GeneratedMethodAccessor375.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
      	at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
      	at com.cloudbees.groovy.cps.Next.step(Next.java:83)
      	at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
      	at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
      	at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129)
      	at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
      	at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
      	at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:186)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:370)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:93)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:282)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:270)
      	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131)
      	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(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)
      Finished: FAILURE 

        Attachments

          Issue Links

            Activity

            Hide
            dicomj23 Dicom J added a comment -

            Jesse Glick, could you please address this one by assigning to the right person, etc. Thanks!

            Show
            dicomj23 Dicom J added a comment - Jesse Glick , could you please address this one by assigning to the right person, etc. Thanks!
            Hide
            jglick Jesse Glick added a comment -

            You may not implement such an extension in Groovy, only in Java.

            Really I should never have introduced the withContext step, and it ought to be deprecated now.

            Show
            jglick Jesse Glick added a comment - You may not implement such an extension in Groovy, only in Java. Really I should never have introduced the withContext step, and it ought to be deprecated now.
            Hide
            dicomj23 Dicom J added a comment -

            Jesse Glick, It's very valuable intel ! At least, we have it documented, as I see people try to do such things and I tried myself as writing +1 groovy module distributed as a part of library looked much easier to me than developing full fledged plugin. Anyways, thanks for clarification!

            Show
            dicomj23 Dicom J added a comment - Jesse Glick , It's very valuable intel ! At least, we have it documented, as I see people try to do such things and I tried myself as writing +1 groovy module distributed as a part of library looked much easier to me than developing full fledged plugin. Anyways, thanks for clarification!

              People

              • Assignee:
                jglick Jesse Glick
                Reporter:
                dicomj23 Dicom J
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: