Put it in a method annotated with @NonCPS

torsdag 13. oktober 2016 11.18.12 UTC+2 skrev eid badr følgende:
>
> Hi
>
> in jenkinsFile.groovy I want to iterate over a properties file, but I 
> always get an error
> how can it be done properly with no error?
>
> node('master') {
>     Properties properties = new Properties()
>     properties.load(new 
> FileInputStream("${env.JENKINS_HOME}\\properties\\${file}"))
>
>     for(Entry<Object, Object> en : properties.entrySet()) {
>         System.out.println(en);
>     }
>
>     /*for(Object k:properties.keySet()) {
>         String key = (String) k;
>     } */ // same error
>  /*   Enumeration en = properties.propertyNames();
>     while (en.hasMoreElements()) {
>         String key = (String) en.nextElement();
>         System.out.println(key + " -- " + properties.getProperty(key));
>     }*/ // same error
> }
>
>
>
>
> java.io.NotSerializableException: java.util.Hashtable$Entry
>       at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860)
>       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(Unknown Source)
>       at java.util.HashMap.internalWriteEntries(Unknown Source)
>       at java.util.HashMap.writeObject(Unknown Source)
>       at sun.reflect.GeneratedMethodAccessor126.invoke(Unknown Source)
>       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>       at java.lang.reflect.Method.invoke(Unknown Source)
>       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.doWriteSerializableObject(RiverMarshaller.java:967)
>       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.doWriteSerializableObject(RiverMarshaller.java:967)
>       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.doWriteSerializableObject(RiverMarshaller.java:967)
>       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.doWriteSerializableObject(RiverMarshaller.java:967)
>       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.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(Unknown Source)
>       at java.util.TreeMap.writeObject(Unknown Source)
>       at sun.reflect.GeneratedMethodAccessor424.invoke(Unknown Source)
>       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>       at java.lang.reflect.Method.invoke(Unknown Source)
>       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:132)
>       at 
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:429)
>       at 
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:408)
>       at 
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:356)
>       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(Unknown Source)
>       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(Unknown Source)
>       at java.util.concurrent.FutureTask.run(Unknown Source)
>       at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
>       at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
>       at java.lang.Thread.run(Unknown Source)
> Caused by: an exception which occurred:
>       in field locals
>       in field parent
>       in field caller
>       in field e
>       in field program
>       in field threads
>       in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@19eb7bd
> Finished: FAILURE
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/b4094f2f-10f3-4759-a002-49b3604b6f1c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to