[workflow-plugin] getting error: java.io.NotSerializableException: java.util.HashMap$Entry

3,560 views
Skip to first unread message

Adam R. Paul

unread,
Mar 31, 2015, 3:58:27 PM3/31/15
to jenkins...@googlegroups.com
Hello,

I'm working on my first workflow job, using Jenkins LTS 1.596.2 &
workflow 1.4, and am getting the following error:

[...]
Running: Execute sub-workflows in parallel : Body : End
Running: End of Workflow
java.io.NotSerializableException: java.util.HashMap$Entry
[...]

I confess I am not yet fluent in groovy, and only passingly familiar
with java, so this may be something simple/stupid, but googling around
didn't show anything that seemed applicable.

The relevant except of my workflow is:

"""
def bport_cmds = [:]

// first determine the RTIs/bugs to backport:
node ("gates") {
runscript("01_gen_buglist -s ${SCRIPT_HOME}/../not-in-sru-bugs -u
${SCRIPT_HOME}/../in-update-bugs")
def j = readFile("build.params")
//echo j.toString()
def rti = new JsonSlurper().parseText(j.toString())

// populate map of backport commands to run in parallel
for (Map.Entry<String, List> entry : rti.entrySet()) {
def script = "02_do_backports -r " + entry.getKey() + " -b "
def cnt = 0
for (bug in entry.getValue()) {
if (cnt == 0) {
script += bug
} else {
script += "," + bug
}
cnt++
}
bport_cmds[entry.getKey()] = { echo "Would have run " + script }
}
rti = null
}

echo bport_cmds.toString()

// run the backports in parallel:
parallel bport_cmds
bport_cmds = null
"""

Before adding the parallel call, everything works as expected.

Any ideas?

The <redacted> console output is:

"""
Started by user anonymous
Running: Allocate node : Start
Running on <host> in <dir>
Running: Allocate node : Body : Start
Running: Shell Script
<01_genbuglist script output>
Running: Read file from workspace
Running: Allocate node : Body : End
Running: Allocate node : End
Running: Print Message
[403412:com.cloudbees.groovy.cps.impl.CpsClosure@3d839d,
403850:com.cloudbees.groovy.cps.impl.CpsClosure@1bf9ea2,
402337:com.cloudbees.groovy.cps.impl.CpsClosure@147a2ae]
Running: Execute sub-workflows in parallel : Start
[403412] Running: Parallel branch: 403412
[403850] Running: Parallel branch: 403850
[402337] Running: Parallel branch: 402337
[403412] Running: Print Message
[403412] Would have run 02_do_backports -r 403412 -b 19320107
Running: Execute sub-workflows in parallel : Body : End
[403850] Running: Print Message
[403850] Would have run 02_do_backports -r 403850 -b 19863042,19404161
Running: Execute sub-workflows in parallel : Body : End
[402337] Running: Print Message
[402337] Would have run 02_do_backports -r 402337 -b 17500325
Running: Execute sub-workflows in parallel : Body : End
Running: End of Workflow
java.io.NotSerializableException: java.util.HashMap$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(ObjectOutputStream.java:343)
at java.util.HashMap.writeObject(HashMap.java:1129)
at sun.reflect.GeneratedMethodAccessor27.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
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.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(ObjectOutputStream.java:343)
at java.util.HashMap.writeObject(HashMap.java:1129)
at sun.reflect.GeneratedMethodAccessor27.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
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.doWriteSerializableObject(RiverMarshaller.java:967)
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:343)
at java.util.HashMap.writeObject(HashMap.java:1129)
at sun.reflect.GeneratedMethodAccessor27.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
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.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.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.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.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:343)
at java.util.HashMap.writeObject(HashMap.java:1129)
at sun.reflect.GeneratedMethodAccessor27.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
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:133)
at
org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:341)
at
org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:325)
at
org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:300)
at
org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$000(CpsThreadGroup.java:71)
at
org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:177)
at
org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:175)
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:111)
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: an exception which occurred:
in field locals
in field parent
in field capture
in field def
in field locals
in field capture
in field def
in field delegate
in field closures
in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@4622d3
Finished: FAILURE
"""

Thanks!
Adam

Angelo Cuttitta

unread,
May 27, 2015, 3:02:32 AM5/27/15
to jenkins...@googlegroups.com, adam...@oracle.com
Dear,
 
 
I'm facing to the same kind of issue, trying to run multiple jobs in parallel.
Hence, unfortunately, I can't help you... :-(
 
I was just wondering if you found a solution, since you posted your message?
 
Kr,
A.

Nyc, Petr

unread,
Jun 2, 2015, 3:41:20 AM6/2/15
to jenkins...@googlegroups.com
Hi,

I was having the same issue. Surprisingly, when you use c-style loop with index, it works. Something like this:

for ( pindex = 0; pindex < pkgs.size(); pindex++ ) {
    for ( bindex = 0; bindex < build_machines.size(); bindex++ ) {
        bmachine = build_machines[bindex]
        def pkg = pkgs[pindex].trim()
        branches["${bmachine}-${pkg}"] = {
            node("${bmachine}") {
                //do something
            }
        }
    }
}

Please let me know, if this worked for you.


--
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-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/bf752fcb-ce30-4bdc-acb2-cee8ab9ec715%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Jesse Glick

unread,
Jun 16, 2015, 2:18:02 PM6/16/15
to jenkins...@googlegroups.com
Message has been deleted

Yury Nedelyaev

unread,
Jul 15, 2015, 4:18:09 AM7/15/15
to jenkins...@googlegroups.com, adam...@oracle.com
https://github.com/jenkinsci/workflow-plugin/blob/master/TUTORIAL.md#serialization-of-local-variables
This is a feature
either create a class with Serializable interface or use 'simple' objects instead of Hashmap

Hello,

I'm working on my first workflow job, using Jenkins LTS 1.596.2 &
workflow 1.4, and am getting the following error:

[...]
Running: Execute sub-workflows in parallel : Body : End
Running: End of Workflow
java.io.NotSerializableException: java.util.HashMap$Entry
[...] 
 
Thanks!
     Adam
Reply all
Reply to author
Forward
0 new messages