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

Pipeline withMaven Failed to serialize on agent

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • pipeline-maven-plugin

      Hi,

      I have a pipeline that runs fine when scheduled on an agent:

      node {
        try {
          stage('Checkout') {
            checkout scm
            checkout scm: [$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'templates']], submoduleCfg: [], userRemoteConfigs: [[url: 'github.com:xxx.git', credentialsId: 'xxx']]], poll: true
          }
          currentBuild.result = 'SUCCESS'
        } catch (e) {
          currentBuild.result = 'FAILURE'
          throw e
        } finally {
          step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'xxx', sendToIndividuals: false])
        }
      }
      

      but when I use withMaven, I get an Exception:

      node {
        try {
          stage('Checkout') {
            checkout scm
            checkout scm: [$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'templates']], submoduleCfg: [], userRemoteConfigs: [[url: 'github.com:xxx.git', credentialsId: 'xxx']]], poll: true
          }
          stage('Test') {
            withMaven(jdk: 'default', maven: 'default') {
              sh "mvn clean test"
            }
            step([$class: 'JUnitResultArchiver', testResults: 'target/surefire-reports/*.xml'])
          }
          currentBuild.result = 'SUCCESS'
        } catch (e) {
          currentBuild.result = 'FAILURE'
          throw e
        } finally {
          step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'xxx', sendToIndividuals: false])
        }
      }
      

      Exception

      java.lang.RuntimeException: Failed to serialize org.jenkinsci.plugins.workflow.support.storage.SimpleXStreamFlowNodeStorage$Tag#actions for class org.jenkinsci.plugins.workflow.support.storage.SimpleXStreamFlowNodeStorage$Tag
      	at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:256)
      	at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224)
      	at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
      	at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209)
      	at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150)
      	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
      	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
      	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
      	at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:82)
      	at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37)
      	at com.thoughtworks.xstream.XStream.marshal(XStream.java:1026)
      	at com.thoughtworks.xstream.XStream.marshal(XStream.java:1015)
      	at com.thoughtworks.xstream.XStream.toXML(XStream.java:988)
      	at hudson.XmlFile.write(XmlFile.java:178)
      	at org.jenkinsci.plugins.workflow.support.storage.SimpleXStreamFlowNodeStorage.saveActions(SimpleXStreamFlowNodeStorage.java:109)
      	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.saveActions(CpsFlowExecution.java:886)
      	at org.jenkinsci.plugins.workflow.graph.FlowNode.save(FlowNode.java:315)
      	at org.jenkinsci.plugins.workflow.graph.FlowNode$1.persist(FlowNode.java:302)
      	at org.jenkinsci.plugins.workflow.graph.FlowNode$1.add(FlowNode.java:278)
      	at org.jenkinsci.plugins.workflow.graph.FlowNode$1.add(FlowNode.java:269)
      	at java.util.AbstractList.add(AbstractList.java:108)
      	at hudson.model.Actionable.addAction(Actionable.java:129)
      	at org.jenkinsci.plugins.workflow.cps.FlowHead.markIfFail(FlowHead.java:142)
      	at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:211)
      	at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:126)
      	at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:120)
      	at groovy.lang.GroovyObject$invokeMethod.call(Unknown Source)
      	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:151)
      	at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:21)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:115)
      	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123)
      	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:16)
      	at WorkflowScript.run(WorkflowScript:8)
      	at ___cps.transform___(Native Method)
      	at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:48)
      	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.GeneratedMethodAccessor383.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
      	at com.cloudbees.groovy.cps.impl.ClosureBlock.eval(ClosureBlock.java:46)
      	at com.cloudbees.groovy.cps.Next.step(Next.java:58)
      	at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:33)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:30)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:30)
      	at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:164)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:324)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:78)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:236)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:224)
      	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:47)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      	at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
      	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      	at java.lang.Thread.run(Thread.java:745)
      Caused by: java.lang.RuntimeException: Failed to serialize org.jenkinsci.plugins.workflow.actions.ErrorAction#error for class org.jenkinsci.plugins.workflow.actions.ErrorAction
      	at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:256)
      	at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224)
      	at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
      	at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209)
      	at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150)
      	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
      	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
      	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
      	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88)
      	at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:64)
      	at com.thoughtworks.xstream.converters.collections.ArrayConverter.marshal(ArrayConverter.java:45)
      	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
      	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
      	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
      	at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265)
      	at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252)
      	at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224)
      	at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
      	at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209)
      	at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150)
      	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
      	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
      	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
      	at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:82)
      	at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37)
      	at com.thoughtworks.xstream.XStream.marshal(XStream.java:1026)
      	at com.thoughtworks.xstream.XStream.marshal(XStream.java:1015)
      	at com.thoughtworks.xstream.XStream.toXML(XStream.java:988)
      	at hudson.XmlFile.write(XmlFile.java:178)
      	at org.jenkinsci.plugins.workflow.support.storage.SimpleXStreamFlowNodeStorage.saveActions(SimpleXStreamFlowNodeStorage.java:109)
      	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.saveActions(CpsFlowExecution.java:886)
      	at org.jenkinsci.plugins.workflow.graph.FlowNode.save(FlowNode.java:315)
      	at org.jenkinsci.plugins.workflow.graph.FlowNode$1.persist(FlowNode.java:302)
      	at org.jenkinsci.plugins.workflow.graph.FlowNode$1.add(FlowNode.java:278)
      	at org.jenkinsci.plugins.workflow.graph.FlowNode$1.add(FlowNode.java:269)
      	at java.util.AbstractList.add(AbstractList.java:108)
      	at hudson.model.Actionable.addAction(Actionable.java:129)
      	at org.jenkinsci.plugins.workflow.cps.FlowHead.markIfFail(FlowHead.java:142)
      	at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:211)
      	at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:126)
      	at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:120)
      	at groovy.lang.GroovyObject$invokeMethod.call(Unknown Source)
      	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:151)
      	at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:21)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:115)
      	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123)
      	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:16)
      	... 29 more
      Caused by: java.lang.UnsupportedOperationException: Refusing to marshal com.google.inject.CreationException for security reasons
      	at hudson.util.XStream2$BlacklistedTypesConverter.marshal(XStream2.java:442)
      	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
      	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
      	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
      	at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265)
      	at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252)
      	... 80 more
      Finished: FAILURE
      

      The pipeline runs successfully when scheduled on the master.

          [JENKINS-38445] Pipeline withMaven Failed to serialize on agent

          Michael Wittig created issue -
          Michael Wittig made changes -
          Description Original: Hi,

          I have a pipeline that runs fine when scheduled on an agent:

          {code:java}
          node {
            try {
              stage('Checkout') {
                checkout scm
                checkout scm: [$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'templates']], submoduleCfg: [], userRemoteConfigs: [[url: 'github.com:xxx.git', credentialsId: 'xxx']]], poll: true
              }
              currentBuild.result = 'SUCCESS'
            } catch (e) {
              currentBuild.result = 'FAILURE'
              throw e
            } finally {
              step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'xxx', sendToIndividuals: false])
            }
          }
          {code}

          but when I use withMaven, I get an Exception:

          {code:java}
          node {
            try {
              stage('Checkout') {
                checkout scm
                checkout scm: [$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'templates']], submoduleCfg: [], userRemoteConfigs: [[url: 'github.com:xxx.git', credentialsId: 'xxx']]], poll: true
              }
              stage('Test') {
                withMaven(jdk: 'default', maven: 'default', ) {
                  sh "mvn clean test"
                }
                step([$class: 'JUnitResultArchiver', testResults: 'target/surefire-reports/*.xml'])
              }
              currentBuild.result = 'SUCCESS'
            } catch (e) {
              currentBuild.result = 'FAILURE'
              throw e
            } finally {
              step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'xxx', sendToIndividuals: false])
            }
          }
          {code}

          Exception
          {noformat}
          java.lang.RuntimeException: Failed to serialize org.jenkinsci.plugins.workflow.support.storage.SimpleXStreamFlowNodeStorage$Tag#actions for class org.jenkinsci.plugins.workflow.support.storage.SimpleXStreamFlowNodeStorage$Tag
          at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:256)
          at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224)
          at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
          at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209)
          at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150)
          at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
          at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
          at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
          at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:82)
          at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37)
          at com.thoughtworks.xstream.XStream.marshal(XStream.java:1026)
          at com.thoughtworks.xstream.XStream.marshal(XStream.java:1015)
          at com.thoughtworks.xstream.XStream.toXML(XStream.java:988)
          at hudson.XmlFile.write(XmlFile.java:178)
          at org.jenkinsci.plugins.workflow.support.storage.SimpleXStreamFlowNodeStorage.saveActions(SimpleXStreamFlowNodeStorage.java:109)
          at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.saveActions(CpsFlowExecution.java:886)
          at org.jenkinsci.plugins.workflow.graph.FlowNode.save(FlowNode.java:315)
          at org.jenkinsci.plugins.workflow.graph.FlowNode$1.persist(FlowNode.java:302)
          at org.jenkinsci.plugins.workflow.graph.FlowNode$1.add(FlowNode.java:278)
          at org.jenkinsci.plugins.workflow.graph.FlowNode$1.add(FlowNode.java:269)
          at java.util.AbstractList.add(AbstractList.java:108)
          at hudson.model.Actionable.addAction(Actionable.java:129)
          at org.jenkinsci.plugins.workflow.cps.FlowHead.markIfFail(FlowHead.java:142)
          at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:211)
          at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:126)
          at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:120)
          at groovy.lang.GroovyObject$invokeMethod.call(Unknown Source)
          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:151)
          at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:21)
          at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:115)
          at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149)
          at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146)
          at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123)
          at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123)
          at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:16)
          at WorkflowScript.run(WorkflowScript:8)
          at ___cps.transform___(Native Method)
          at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:48)
          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.GeneratedMethodAccessor383.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:606)
          at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
          at com.cloudbees.groovy.cps.impl.ClosureBlock.eval(ClosureBlock.java:46)
          at com.cloudbees.groovy.cps.Next.step(Next.java:58)
          at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154)
          at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
          at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:33)
          at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:30)
          at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
          at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:30)
          at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:164)
          at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:324)
          at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:78)
          at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:236)
          at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:224)
          at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:47)
          at java.util.concurrent.FutureTask.run(FutureTask.java:262)
          at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
          at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
          at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
          at java.util.concurrent.FutureTask.run(FutureTask.java:262)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
          at java.lang.Thread.run(Thread.java:745)
          Caused by: java.lang.RuntimeException: Failed to serialize org.jenkinsci.plugins.workflow.actions.ErrorAction#error for class org.jenkinsci.plugins.workflow.actions.ErrorAction
          at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:256)
          at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224)
          at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
          at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209)
          at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150)
          at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
          at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
          at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
          at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88)
          at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:64)
          at com.thoughtworks.xstream.converters.collections.ArrayConverter.marshal(ArrayConverter.java:45)
          at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
          at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
          at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
          at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265)
          at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252)
          at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224)
          at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
          at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209)
          at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150)
          at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
          at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
          at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
          at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:82)
          at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37)
          at com.thoughtworks.xstream.XStream.marshal(XStream.java:1026)
          at com.thoughtworks.xstream.XStream.marshal(XStream.java:1015)
          at com.thoughtworks.xstream.XStream.toXML(XStream.java:988)
          at hudson.XmlFile.write(XmlFile.java:178)
          at org.jenkinsci.plugins.workflow.support.storage.SimpleXStreamFlowNodeStorage.saveActions(SimpleXStreamFlowNodeStorage.java:109)
          at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.saveActions(CpsFlowExecution.java:886)
          at org.jenkinsci.plugins.workflow.graph.FlowNode.save(FlowNode.java:315)
          at org.jenkinsci.plugins.workflow.graph.FlowNode$1.persist(FlowNode.java:302)
          at org.jenkinsci.plugins.workflow.graph.FlowNode$1.add(FlowNode.java:278)
          at org.jenkinsci.plugins.workflow.graph.FlowNode$1.add(FlowNode.java:269)
          at java.util.AbstractList.add(AbstractList.java:108)
          at hudson.model.Actionable.addAction(Actionable.java:129)
          at org.jenkinsci.plugins.workflow.cps.FlowHead.markIfFail(FlowHead.java:142)
          at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:211)
          at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:126)
          at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:120)
          at groovy.lang.GroovyObject$invokeMethod.call(Unknown Source)
          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:151)
          at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:21)
          at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:115)
          at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149)
          at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146)
          at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123)
          at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123)
          at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:16)
          ... 29 more
          Caused by: java.lang.UnsupportedOperationException: Refusing to marshal com.google.inject.CreationException for security reasons
          at hudson.util.XStream2$BlacklistedTypesConverter.marshal(XStream2.java:442)
          at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
          at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
          at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
          at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265)
          at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252)
          ... 80 more
          Finished: FAILURE
          {noformat}


          The pipeline runs successfully when scheduled on the master.
          New: Hi,

          I have a pipeline that runs fine when scheduled on an agent:

          {code:java}
          node {
            try {
              stage('Checkout') {
                checkout scm
                checkout scm: [$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'templates']], submoduleCfg: [], userRemoteConfigs: [[url: 'github.com:xxx.git', credentialsId: 'xxx']]], poll: true
              }
              currentBuild.result = 'SUCCESS'
            } catch (e) {
              currentBuild.result = 'FAILURE'
              throw e
            } finally {
              step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'xxx', sendToIndividuals: false])
            }
          }
          {code}

          but when I use withMaven, I get an Exception:

          {code:java}
          node {
            try {
              stage('Checkout') {
                checkout scm
                checkout scm: [$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'templates']], submoduleCfg: [], userRemoteConfigs: [[url: 'github.com:xxx.git', credentialsId: 'xxx']]], poll: true
              }
              stage('Test') {
                withMaven(jdk: 'default', maven: 'default') {
                  sh "mvn clean test"
                }
                step([$class: 'JUnitResultArchiver', testResults: 'target/surefire-reports/*.xml'])
              }
              currentBuild.result = 'SUCCESS'
            } catch (e) {
              currentBuild.result = 'FAILURE'
              throw e
            } finally {
              step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'xxx', sendToIndividuals: false])
            }
          }
          {code}

          Exception
          {noformat}
          java.lang.RuntimeException: Failed to serialize org.jenkinsci.plugins.workflow.support.storage.SimpleXStreamFlowNodeStorage$Tag#actions for class org.jenkinsci.plugins.workflow.support.storage.SimpleXStreamFlowNodeStorage$Tag
          at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:256)
          at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224)
          at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
          at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209)
          at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150)
          at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
          at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
          at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
          at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:82)
          at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37)
          at com.thoughtworks.xstream.XStream.marshal(XStream.java:1026)
          at com.thoughtworks.xstream.XStream.marshal(XStream.java:1015)
          at com.thoughtworks.xstream.XStream.toXML(XStream.java:988)
          at hudson.XmlFile.write(XmlFile.java:178)
          at org.jenkinsci.plugins.workflow.support.storage.SimpleXStreamFlowNodeStorage.saveActions(SimpleXStreamFlowNodeStorage.java:109)
          at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.saveActions(CpsFlowExecution.java:886)
          at org.jenkinsci.plugins.workflow.graph.FlowNode.save(FlowNode.java:315)
          at org.jenkinsci.plugins.workflow.graph.FlowNode$1.persist(FlowNode.java:302)
          at org.jenkinsci.plugins.workflow.graph.FlowNode$1.add(FlowNode.java:278)
          at org.jenkinsci.plugins.workflow.graph.FlowNode$1.add(FlowNode.java:269)
          at java.util.AbstractList.add(AbstractList.java:108)
          at hudson.model.Actionable.addAction(Actionable.java:129)
          at org.jenkinsci.plugins.workflow.cps.FlowHead.markIfFail(FlowHead.java:142)
          at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:211)
          at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:126)
          at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:120)
          at groovy.lang.GroovyObject$invokeMethod.call(Unknown Source)
          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:151)
          at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:21)
          at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:115)
          at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149)
          at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146)
          at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123)
          at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123)
          at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:16)
          at WorkflowScript.run(WorkflowScript:8)
          at ___cps.transform___(Native Method)
          at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:48)
          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.GeneratedMethodAccessor383.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:606)
          at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
          at com.cloudbees.groovy.cps.impl.ClosureBlock.eval(ClosureBlock.java:46)
          at com.cloudbees.groovy.cps.Next.step(Next.java:58)
          at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154)
          at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
          at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:33)
          at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:30)
          at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
          at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:30)
          at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:164)
          at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:324)
          at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:78)
          at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:236)
          at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:224)
          at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:47)
          at java.util.concurrent.FutureTask.run(FutureTask.java:262)
          at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
          at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
          at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
          at java.util.concurrent.FutureTask.run(FutureTask.java:262)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
          at java.lang.Thread.run(Thread.java:745)
          Caused by: java.lang.RuntimeException: Failed to serialize org.jenkinsci.plugins.workflow.actions.ErrorAction#error for class org.jenkinsci.plugins.workflow.actions.ErrorAction
          at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:256)
          at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224)
          at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
          at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209)
          at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150)
          at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
          at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
          at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
          at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88)
          at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:64)
          at com.thoughtworks.xstream.converters.collections.ArrayConverter.marshal(ArrayConverter.java:45)
          at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
          at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
          at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
          at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265)
          at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252)
          at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224)
          at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
          at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209)
          at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150)
          at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
          at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
          at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
          at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:82)
          at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37)
          at com.thoughtworks.xstream.XStream.marshal(XStream.java:1026)
          at com.thoughtworks.xstream.XStream.marshal(XStream.java:1015)
          at com.thoughtworks.xstream.XStream.toXML(XStream.java:988)
          at hudson.XmlFile.write(XmlFile.java:178)
          at org.jenkinsci.plugins.workflow.support.storage.SimpleXStreamFlowNodeStorage.saveActions(SimpleXStreamFlowNodeStorage.java:109)
          at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.saveActions(CpsFlowExecution.java:886)
          at org.jenkinsci.plugins.workflow.graph.FlowNode.save(FlowNode.java:315)
          at org.jenkinsci.plugins.workflow.graph.FlowNode$1.persist(FlowNode.java:302)
          at org.jenkinsci.plugins.workflow.graph.FlowNode$1.add(FlowNode.java:278)
          at org.jenkinsci.plugins.workflow.graph.FlowNode$1.add(FlowNode.java:269)
          at java.util.AbstractList.add(AbstractList.java:108)
          at hudson.model.Actionable.addAction(Actionable.java:129)
          at org.jenkinsci.plugins.workflow.cps.FlowHead.markIfFail(FlowHead.java:142)
          at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:211)
          at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:126)
          at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:120)
          at groovy.lang.GroovyObject$invokeMethod.call(Unknown Source)
          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:151)
          at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:21)
          at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:115)
          at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149)
          at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146)
          at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123)
          at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123)
          at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:16)
          ... 29 more
          Caused by: java.lang.UnsupportedOperationException: Refusing to marshal com.google.inject.CreationException for security reasons
          at hudson.util.XStream2$BlacklistedTypesConverter.marshal(XStream2.java:442)
          at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
          at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
          at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
          at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265)
          at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252)
          ... 80 more
          Finished: FAILURE
          {noformat}


          The pipeline runs successfully when scheduled on the master.

          max allan added a comment -

          I was having a similar error message and problem with withMaven not running on either slave or master.
          Updated all plugins and core Jenkins from 2.21 to 2.23 and it seems to be working.
          The cause is unknown, I'm pretty sure it was working with the old versions of everything...

          max allan added a comment - I was having a similar error message and problem with withMaven not running on either slave or master. Updated all plugins and core Jenkins from 2.21 to 2.23 and it seems to be working. The cause is unknown, I'm pretty sure it was working with the old versions of everything...

          Alvaro Lobato added a comment -

          Are you sure this is related to withMaven?, see: https://issues.jenkins-ci.org/browse/JENKINS-38122

          Alvaro Lobato added a comment - Are you sure this is related to withMaven?, see: https://issues.jenkins-ci.org/browse/JENKINS-38122

          The only thing I know is that without the withMaven it works. I found JENKINS-38122 before opening this issue but the solution to the problem is missing in the ticket.

          I now use a workaround with a docker container to provide maven and it works for me:

          Jenkinsfile

            def environment  = docker.build 'xyz:snapshot'
              environment.inside {
                stage('Test') {
                  sh "mvn clean test"
                  step([$class: 'JUnitResultArchiver', testResults: 'target/surefire-reports/*.xml'])
                }
              }
          

          Dockerfile

          FROM centos:7.2.1511
          
          RUN yum -y install epel-release
          RUN yum -y install python-pip java-1.8.0-openjdk-devel wget
          
          RUN wget -q -P / http://mirror.dkd.de/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz && mkdir /maven/ && tar xzvf /apache-maven-3.3.9-bin.tar.gz -C /maven/ --strip-components=1
          
          ENV MAVEN_HOME=/maven
          ENV PATH=/maven/bin/:$PATH
          ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk
          
          RUN groupadd -g 497 jenkins
          RUN adduser -u 498 -g 497 -s /bin/false -d /var/lib/jenkins -c 'Jenkins Continuous Integration Server' jenkins
          USER jenkins
          

          Michael Wittig added a comment - The only thing I know is that without the withMaven it works. I found JENKINS-38122 before opening this issue but the solution to the problem is missing in the ticket. I now use a workaround with a docker container to provide maven and it works for me: Jenkinsfile def environment = docker.build 'xyz:snapshot' environment.inside { stage( 'Test' ) { sh "mvn clean test" step([$class: 'JUnitResultArchiver' , testResults: 'target/surefire-reports/*.xml' ]) } } Dockerfile FROM centos:7.2.1511 RUN yum -y install epel-release RUN yum -y install python-pip java-1.8.0-openjdk-devel wget RUN wget -q -P / http: //mirror.dkd.de/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz && mkdir /maven/ && tar xzvf /apache-maven-3.3.9-bin.tar.gz -C /maven/ --strip-components=1 ENV MAVEN_HOME=/maven ENV PATH=/maven/bin/:$PATH ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk RUN groupadd -g 497 jenkins RUN adduser -u 498 -g 497 -s /bin/ false -d / var /lib/jenkins -c 'Jenkins Continuous Integration Server' jenkins USER jenkins

          XStream refuses to serialize com.google.inject.CreationException. I have seen it debugging a problem on the Configuration File Provider Plugin.

          The root cause of the problem was hidden by this XStream serialization exception. Maybe we could improve Jenkins / Xstream doing one of the following:

          Cyrille Le Clerc added a comment - XStream refuses to serialize com.google.inject.CreationException . I have seen it debugging a problem on the Configuration File Provider Plugin. The root cause of the problem was hidden by this XStream serialization exception. Maybe we could improve Jenkins / Xstream doing one of the following: Make Jenkins capable of serializing com.google.inject.CreationException so that the root exception is not hidden Add a log message in hudson.util.XStream2.BlacklistedTypesConverter#marshal

          • The error message if the JDK name is invalid is the expected message: "ERROR: Could not find the JDK installation: default-does-not-exist. Make sure it is configured on the Global Tool Configuration page"
          • The error message if both JDK names and Maven name are invalid is a good message: "ERROR: Could not find the JDK installation: default-does-not-exist. Make sure it is configured on the Global Tool Configuration page"
          • The error message if the Maven name is invalid is the good message: "ERROR: Could not find 'default-does-not-exist' maven installation."

          Cyrille Le Clerc added a comment - The error message if the JDK name is invalid is the expected message: "ERROR: Could not find the JDK installation: default-does-not-exist. Make sure it is configured on the Global Tool Configuration page" The error message if both JDK names and Maven name are invalid is a good message: "ERROR: Could not find the JDK installation: default-does-not-exist. Make sure it is configured on the Global Tool Configuration page" The error message if the Maven name is invalid is the good message: "ERROR: Could not find 'default-does-not-exist' maven installation."

          Michael I get a 404 "This page has been removed!" trying to get the details of your environment on pastebin. Could you share with us details?

          Cyrille Le Clerc added a comment - Michael I get a 404 "This page has been removed!" trying to get the details of your environment on pastebin. Could you share with us details?

          I got an error:

          Caused by: java.lang.UnsupportedOperationException: Refusing to marshal com.google.inject.CreationException for security reasons
          	at hudson.util.XStream2$BlacklistedTypesConverter.marshal(XStream2.java:442)
          	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
          	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
          	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
          	at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265)
          	at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252)
          	... 76 more
          

          when make symlink workspace to another folder

          Denis Saponenko added a comment - I got an error: Caused by: java.lang.UnsupportedOperationException: Refusing to marshal com.google.inject.CreationException for security reasons at hudson.util.XStream2$BlacklistedTypesConverter.marshal(XStream2.java:442) at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69) at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58) at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84) at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265) at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252) ... 76 more when make symlink workspace to another folder

          Hello Denis,

          We seem to have a problem with the c.g.i.CreationException that gets hidden by the XStream2$BlacklistedTypesConverter and this problem hides the root cause of your problem.

          We are working at fixing the problem with the BlacklistedTypesConverter that hides the the c.g.i.CreationException.

          Can you detail more what is the symlink that cause your failure? Can you provide an "ls -al" of the parent folder ...

          Cyrille Le Clerc added a comment - Hello Denis, We seem to have a problem with the c.g.i.CreationException that gets hidden by the XStream2$BlacklistedTypesConverter and this problem hides the root cause of your problem. We are working at fixing the problem with the BlacklistedTypesConverter that hides the the c.g.i.CreationException. Can you detail more what is the symlink that cause your failure? Can you provide an "ls -al" of the parent folder ...

            alobato Alvaro Lobato
            michaelwittig Michael Wittig
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: