title: java.io.NotSerializableException Error in Pipeline Scripting
body: <p>I'm using below code to load a Groovy file and to pass parameter:</p>
  
  <blockquote>
    <p>Pipeline Script in jenkins</p>
  </blockquote>
  
  <pre><code>@NonCPS 
  def ld() { 
     def pck = load '/tmp/Provsioning/e.groovy'; 
     return pck.xmlParseData("${params.hos_nam}");
  } 
  node { 
     stage ('Deploying Packages'){ 
        def aby = ld(); 
     } 
  }
  </code></pre>
  
  <p>where <code>${params.hos_nam}</code> is a build parameter and the <code>installpackage</code> groovy follows as below </p>
  
  <blockquote>
    <p>/tmp/Provsioning/e.groovy</p>
  </blockquote>
  
  <pre><code>public class ReadXMLFile {
     def xmlParseData(String g){
        installPackage(a,b,c);
        input 'proceed'
        aemRestart(b);
     }
     def installPackage(String a, String b,String c){
        //some code
     }
     def aemRestart(String a){
        //some code
     }
  }
  </code></pre>
  
  <p>I'm not sure why the below error occurs:</p>
  
  <pre><code>an exception which occurred:
      in field val$body
      in field closures
      in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@67aecf21
      Caused: java.io.NotSerializableException:    org.codehaus.groovy.runtime.InvokerHelper$1
      at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860)
      at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
      at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
      at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
      at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
      at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
      at org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
      at org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
      at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
      at java.util.HashMap.internalWriteEntries(HashMap.java:1785)
      at java.util.HashMap.writeObject(HashMap.java:1362)
      at sun.reflect.GeneratedMethodAccessor198.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:271)
      at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:976)
      at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
      at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
      at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
      at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
      at org.jboss.marshalling.AbstractObjectOutput.writeObject(AbstractObjectOutput.java:58)
      at org.jboss.marshalling.AbstractMarshaller.writeObject(AbstractMarshaller.java:111)
      at org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverWriter.writeObject(RiverWriter.java:140)
      at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:458)
      at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:434)
      at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgramIfPossible(CpsThreadGroup.java:422)
      at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:362)
      at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:82)
  
  Finished: FAILURE
  </code></pre>