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

Pipeline script fails to call Java code on slave: Failed to deserialize the Callable object

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Minor Minor
    • pipeline, remoting
    • None
    • Jenkins server: 2.190.1

      This is a simple pipeline script on which the issue is reproduced:

      import jenkins.security.MasterToSlaveCallable;
      //import hudson.remoting.Callable;
      
      def executeJavaCodeOnNode() {
      
          def node = Jenkins.getInstance().slaves.find({it.name == env.NODE_NAME})
          def hostChannel = node.getComputer().getChannel()
          def task = new MasterToSlaveCallable<String, IOException>() {
                  public String call() throws IOException {
                      return new String("-on the node-");
                  }
          };
              
          hostChannel.call(task);
      }
      
      // Main
      node ('linux-01') {
          executeJavaCodeOnNode()
      }
      

      This simple pipeline script fails with multiple Java exceptions. I think the most relevent of them are:

      java.lang.IllegalArgumentException: Unable to locate class file for class WorkflowScript$1
      	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.GeneratedMethodAccessor753.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: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)
      

      and

      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:1868)
      		at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1751)
      		at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2042)
      		at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1573)
      		at java.io.ObjectInputStream.readObject(ObjectInputStream.java:431)
      		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)
      ....
      ....
      ....
      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)
      

      I thought that this issue is connected to serialization and tried to add @NonCPS to my method, but it did not help.

            jthompson Jeff Thompson
            alexander_samoylov Alexander Samoylov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: