Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle project fails to run with Jenkins v2.277.1 #109

Open
njtman opened this issue Mar 24, 2021 · 4 comments
Open

Gradle project fails to run with Jenkins v2.277.1 #109

njtman opened this issue Mar 24, 2021 · 4 comments

Comments

@njtman
Copy link

njtman commented Mar 24, 2021

The gradle project was running just fine when defining jenkinsVersion=2.263.4 in the gradle.properties file. When bumping the version to jenkinsVersion=2.277.1 the project fails to run and the following error is logged to the console.

It seems to be related to XStream. The 2.277.1 Jenkins release notes explicitly mention that breaking XStream changes are included in this release.

...omitting irrelevant logs...
> Task :test FAILED
file or directory '/home/vagrant/build/classes/java/test', not found
Caching disabled for task ':test' because:
  Build cache is disabled
Task ':test' is not up-to-date because:
  Input property 'classpath' file /home/vagrant/.gradle/caches/modules-2/files-2.1/org.jenkins-ci.main/jenkins-war/2.263.4/591d9ac9a4ad7f48b9b4401b35098bf2c8293e82/jenkins-war-2.263.4.war has been removed.
  Input property 'classpath' file /home/vagrant/.gradle/caches/modules-2/files-2.1/org.jenkins-ci.main/jenkins-core/2.263.4/36f30faa1e981bd68d76f1f274bfd416283cf528/jenkins-core-2.263.4.jar has been removed.
  Input property 'classpath' file /home/vagrant/.gradle/caches/modules-2/files-2.1/org.kohsuke.stapler/stapler-groovy/1.261/30d3c5db4d1589d724779a57c30cf45b4d68c4f/stapler-groovy-1.261.jar has been removed.
file or directory '/home/vagrant/build/classes/java/test', not found
Starting process 'Gradle Test Executor 34'. Working directory: /home/vagrant/ci Command: /usr/lib/jvm/java-8-openjdk-amd64/bin/java -Djava.security.manager=worker.org.gradle.process.internal.worker.child.BootstrapSecurityManager -Dorg.gradle.native=false -Xmx512m -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -ea -cp /home/vagrant/.gradle/caches/6.5/workerMain/gradle-worker.jar worker.org.gradle.process.internal.worker.GradleWorkerMain 'Gradle Test Executor 34'
Successfully started process 'Gradle Test Executor 34'

com.project.jenkins.jobdsl.JobScriptsSpec STANDARD_ERROR
    Mar 24, 2021 5:42:12 PM jenkins.model.Jenkins <clinit>
    SEVERE: Failed to load Jenkins.class
    java.lang.VerifyError: (class: com/thoughtworks/xstream/core/util/SerializationMembers, method: callReadResolve signature: (Ljava/lang/Object;)Ljava/lang/Object;) Incompatible object argument for function call
        at hudson.util.RobustReflectionConverter.<init>(RobustReflectionConverter.java:106)
        at hudson.util.XStream2.setupConverters(XStream2.java:218)
        at com.thoughtworks.xstream.XStream.<init>(XStream.java:574)
        at com.thoughtworks.xstream.XStream.<init>(XStream.java:496)
        at com.thoughtworks.xstream.XStream.<init>(XStream.java:465)
        at com.thoughtworks.xstream.XStream.<init>(XStream.java:411)
        at com.thoughtworks.xstream.XStream.<init>(XStream.java:378)
        at hudson.util.XStream2.<init>(XStream2.java:113)
        at jenkins.model.Jenkins.<clinit>(Jenkins.java:5439)
        at hudson.PluginManager.<clinit>(PluginManager.java:2227)
        at org.jvnet.hudson.test.JenkinsRule.<init>(JenkinsRule.java:333)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
        at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:59)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:238)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:242)
        at com.project.jenkins.jobdsl.JobScriptsSpec.$spock_initializeSharedFields(JobScriptsSpec.groovy:28)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.spockframework.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:200)
        at org.spockframework.runtime.model.MethodInfo.invoke(MethodInfo.java:113)
        at org.spockframework.runtime.BaseSpecRunner.invokeRaw(BaseSpecRunner.java:484)
        at org.spockframework.runtime.BaseSpecRunner.invoke(BaseSpecRunner.java:467)
        at org.spockframework.runtime.BaseSpecRunner.doRunSharedInitializer(BaseSpecRunner.java:145)
        at org.spockframework.runtime.BaseSpecRunner$2.invoke(BaseSpecRunner.java:130)
        at org.spockframework.runtime.BaseSpecRunner.invokeRaw(BaseSpecRunner.java:484)
        at org.spockframework.runtime.BaseSpecRunner.invoke(BaseSpecRunner.java:467)
        at org.spockframework.runtime.BaseSpecRunner.runSharedInitializer(BaseSpecRunner.java:123)
        at org.spockframework.runtime.BaseSpecRunner.runSharedInitializer(BaseSpecRunner.java:118)
        at org.spockframework.runtime.BaseSpecRunner.run(BaseSpecRunner.java:63)
        at org.spockframework.runtime.Sputnik.run(Sputnik.java:63)
        at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
        at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
        at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
        at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
        at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
        at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
        at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
        at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:119)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182)
        at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)
        at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:414)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
        at java.lang.Thread.run(Thread.java:748)


com.project.jenkins.jobdsl.JobScriptsSpec > classMethod FAILED
    java.lang.VerifyError: (class: com/thoughtworks/xstream/core/util/SerializationMembers, method: callReadResolve signature: (Ljava/lang/Object;)Ljava/lang/Object;) Incompatible object argument for function call
        at hudson.util.RobustReflectionConverter.<init>(RobustReflectionConverter.java:106)
        at hudson.util.XStream2.setupConverters(XStream2.java:218)
        at com.thoughtworks.xstream.XStream.<init>(XStream.java:574)
        at com.thoughtworks.xstream.XStream.<init>(XStream.java:496)
        at com.thoughtworks.xstream.XStream.<init>(XStream.java:465)
        at com.thoughtworks.xstream.XStream.<init>(XStream.java:411)
        at com.thoughtworks.xstream.XStream.<init>(XStream.java:378)
        at hudson.util.XStream2.<init>(XStream2.java:113)
        at jenkins.model.Jenkins.<clinit>(Jenkins.java:5439)
        at hudson.PluginManager.<clinit>(PluginManager.java:2227)
        at org.jvnet.hudson.test.JenkinsRule.<init>(JenkinsRule.java:333)
        at com.project.jenkins.jobdsl.JobScriptsSpec.$spock_initializeSharedFields(JobScriptsSpec.groovy:28)

1 test completed, 1 failed
@njtman njtman changed the title Project fails to run with Jenkins v2.277.1 Gradle project fails to run with Jenkins v2.277.1 Mar 24, 2021
@bawjensen
Copy link

Just ran into this yesterday. I'm not super familiar with java systems (including gradle) but I did my best to dig into it regardless. The chain of events:

  • Change gradle.properties to have jenkinsVersion=2.283 (could be 2.277.1, probably doesn't matter)
  • This resulted in the error in the initial report (although my stack trace didn't match exactly, I believe the error was the same)
  • Tracked it down to job-dsl-core per a relevant message to "Jenkins Developers" google group: https://www.mail-archive.com/[email protected]/msg36543.html
  • Removed compile "org.jenkins-ci.plugins:job-dsl-core:${jobDslVersion}" line from build.gradle
  • This caused src/main/groovy/com/dslexample/builder/GradleCiJobBuilder.groovy (as could be expected when removing a dependency)
  • Deleted that GradleCiJobBuilder.groovy file
  • This caused errors in src/test/groovy/com/dslexample/builder/GradleCiJobBuilderSpec.groovy
  • Deleted that test file, too
  • That caused failures on src/jobs/example7Jobs.groovy
  • Deleted that example jobs file
  • It runs without error 🎉

Obviously this isn't much of a fix given the amount of deletions involved. But it points to the fact that job-dsl-core seems to reference the forked version of xstream: https://github.com/jenkinsci/job-dsl-plugin/blob/b3bd3488f6c7389be8df0c7e473d0144c364a6ad/build.gradle#L79-L82. So this may simply be reliant on the other module to update.

However I'm not really able to reconcile that conclusion with the fact that empirically I've got a jenkins instance running on version 2.283 w/ Job [email protected] without issue.

As before, take this all with a grain of salt. My familiarity with all these systems is very limited.

@njtman
Copy link
Author

njtman commented Mar 29, 2021

Just ran into this yesterday. I'm not super familiar with java systems (including gradle) but I did my best to dig into it regardless. The chain of events:

  • Change gradle.properties to have jenkinsVersion=2.283 (could be 2.277.1, probably doesn't matter)
  • This resulted in the error in the initial report (although my stack trace didn't match exactly, I believe the error was the same)
  • Tracked it down to job-dsl-core per a relevant message to "Jenkins Developers" google group: https://www.mail-archive.com/[email protected]/msg36543.html
  • Removed compile "org.jenkins-ci.plugins:job-dsl-core:${jobDslVersion}" line from build.gradle
  • This caused src/main/groovy/com/dslexample/builder/GradleCiJobBuilder.groovy (as could be expected when removing a dependency)
  • Deleted that GradleCiJobBuilder.groovy file
  • This caused errors in src/test/groovy/com/dslexample/builder/GradleCiJobBuilderSpec.groovy
  • Deleted that test file, too
  • That caused failures on src/jobs/example7Jobs.groovy
  • Deleted that example jobs file
  • It runs without error 🎉

Obviously this isn't much of a fix given the amount of deletions involved. But it points to the fact that job-dsl-core seems to reference the forked version of xstream: https://github.com/jenkinsci/job-dsl-plugin/blob/b3bd3488f6c7389be8df0c7e473d0144c364a6ad/build.gradle#L79-L82. So this may simply be reliant on the other module to update.

However I'm not really able to reconcile that conclusion with the fact that empirically I've got a jenkins instance running on version 2.283 w/ Job [email protected] without issue.

As before, take this all with a grain of salt. My familiarity with all these systems is very limited.

Cool, thanks for the additional investigation. I'm using a forked version of this repo. Performing the first mitigation step fixed the project compilation for me.

  • Removed compile "org.jenkins-ci.plugins:job-dsl-core:${jobDslVersion}" line from build.gradle

After making this change, I verified that the xml files are still being generated as expected. I also confirmed that providing invalid job dsl breaks compilation.

@robbinvandamme
Copy link

robbinvandamme commented Jun 18, 2021

Instead of removing job-dsl-core i've exclude xstream

+    compile("org.jenkins-ci.plugins:job-dsl-core:${jobDslVersion}")
+    {
+        exclude module:'xstream'
+    }

@dinhthien1604
Copy link

Hi,

When I change to Jenkins version 2.375.3, it's not work.
Could someone can help, please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants