[JIRA] (JENKINS-37396) java.io.NotSerializableException: groovy.sql.GroovyRowResult

110 views
Skip to first unread message

likeanyotheronlymoreso@gmail.com (JIRA)

unread,
Aug 13, 2016, 6:14:01 PM8/13/16
to jenkinsc...@googlegroups.com
Joe Roberts created an issue
 
Jenkins / Bug JENKINS-37396
java.io.NotSerializableException: groovy.sql.GroovyRowResult
Issue Type: Bug Bug
Assignee: Daniel Spilker
Components: job-dsl-plugin
Created: 2016/Aug/13 10:13 PM
Environment: Centos 7 (3.10.0-327.22.2.el7.x86_64)
openjdk version "1.8.0_101"
OpenJDK Runtime Environment (build 1.8.0_101-b13)
OpenJDK 64-Bit Server VM (build 25.101-b13, mixed mode)
Jenkins 2.17
Job DSL plugin 1.48
Priority: Blocker Blocker
Reporter: Joe Roberts

When querying a MySQL database to perform functions on the resulting GroovyRowResults, I receive a NotSerializableException when attempting to use a string value from a GroovyRowResult in a "sh" call.

In my worflow library:

def mergeEmtTag(tag){
    stage 'Connect to database'
    def db = [url:'jdbc:mysql://localhost:3306/jenkins', user:'jenkins_user', password:'xxxxxxxxxx', driver:'com.mysql.jdbc.Driver']
    def sql = Sql.newInstance(db.url, db.user, db.password, db.driver)

    stage 'Retrieve all EMTs'
    def rows = sql.rows("SELECT * FROM emts")
    sql.close()

    for ( i in rows ) {

        sh """
            if [ -d "${i.slug}" ]; then
                mkdir "${i.slug}"
            fi
        """
        dir("${slug}"){
            sh """
                git clone "g...@bitbucket.org:xxxxxxxx/${row.slug}.git" .
                cd $slug
                git remote add upstream g...@bitbucket.org:xxxxxxx/emt-master.git
                git checkout origin/master
                git fetch --tags upstream

                git merge "${tag}"

                if [ \$? -ne 0 ]; then
                    exit -1
                fi

                git branch --set-upstream-to=origin/master master
                git push -u origin master
             """
         }
    }
}

Any recommendations on how to accomplish this?

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

likeanyotheronlymoreso@gmail.com (JIRA)

unread,
Aug 13, 2016, 6:15:04 PM8/13/16
to jenkinsc...@googlegroups.com
Joe Roberts commented on Bug JENKINS-37396
 
Re: java.io.NotSerializableException: groovy.sql.GroovyRowResult
java.io.NotSerializableException: groovy.sql.GroovyRowResult
	at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860)
	at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:569)
	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.GeneratedMethodAccessor28.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.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.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.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.TreeMap.writeObject(TreeMap.java:2438)
	at sun.reflect.GeneratedMethodAccessor251.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:132)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:459)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:438)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:392)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:80)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:236)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:226)
	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:47)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	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:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: an exception which occurred:
	in field locals
	in field caller
	in field parent
	in field parent
	in field parent
	in field caller
	in field e
	in field program
	in field threads
	in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@74eb2d2f

mail@daniel-spilker.com (JIRA)

unread,
Aug 15, 2016, 3:20:01 AM8/15/16
to jenkinsc...@googlegroups.com

mail@daniel-spilker.com (JIRA)

unread,
Aug 15, 2016, 3:20:02 AM8/15/16
to jenkinsc...@googlegroups.com
Daniel Spilker updated an issue
Change By: Daniel Spilker
Component/s: workflow-plugin
Component/s: job-dsl-plugin

likeanyotheronlymoreso@gmail.com (JIRA)

unread,
Sep 23, 2016, 6:25:04 PM9/23/16
to jenkinsc...@googlegroups.com
 
Re: java.io.NotSerializableException: groovy.sql.GroovyRowResult

After some testing it would appear that, in order to complete successfully, sql.close() must be the last command in the script. Anything else causes either a groovy.sql.Sql or if you remove the "sql.close" command, a groovy.sql.GroovyRowResult java.io.NotSerializableException.

likeanyotheronlymoreso@gmail.com (JIRA)

unread,
Sep 23, 2016, 6:26:01 PM9/23/16
to jenkinsc...@googlegroups.com
After some testing it would appear that, in order to complete successfully, sql.close() must be the last command in the script. Anything else causes either a groovy.sql.Sql or if you remove the "sql.close" command, a groovy.sql.GroovyRowResult java.io.NotSerializableException.

svanoort@cloudbees.com (JIRA)

unread,
Apr 12, 2018, 11:50:04 AM4/12/18
to jenkinsc...@googlegroups.com
Sam Van Oort closed an issue as Not A Defect
 

AFAICT workflow-api and workflow-cps should now handle nonserializable exceptions as of the latest versions. In general though, you should see an error if you try to save something nonserializable so I consider this not-a-defect... and in general doing this kind of inline DB querying within Pipelines is strongly discouraged.

Change By: Sam Van Oort
Status: Open Closed
Resolution: Not A Defect
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

jean.kon-sun-tack@nielsen.com (JIRA)

unread,
Apr 9, 2019, 9:31:02 AM4/9/19
to jenkinsc...@googlegroups.com
Jean KST commented on Bug JENKINS-37396
 
Re: java.io.NotSerializableException: groovy.sql.GroovyRowResult

Had a similar issue and upgrading to Groovy plugin 2.2 fixed it.

 

This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

jean.kon-sun-tack@nielsen.com (JIRA)

unread,
Apr 9, 2019, 12:45:02 PM4/9/19
to jenkinsc...@googlegroups.com
Jean KST updated an issue
Change By: Jean KST
Comment:
Had a similar issue and upgrading to Groovy plugin 2.2 fixed it.

 
Reply all
Reply to author
Forward
0 new messages