Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-66837

java.lang.LinkageError due to the use of different version of the same library

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • official docker image Jenkins 2.314
      jira-plugin 3.6
      gitlab-plugin 1.5.20

      I'm using the Jira plugin with the Gitlab plugin and I got the following error

      Looks similar to JENKINS-60402 

      How can those plugin can manage to have the same version of librairies ?

      java.lang.LinkageError: ClassCastException: attempting to castjar:file:/var/jenkins_home/plugins/gitlab-plugin/WEB-INF/lib/jboss-jaxrs-api_2.0_spec-1.0.0.Final.jar!/javax/ws/rs/ext/RuntimeDelegate.classtojar:file:/var/jenkins_home/plugins/jira/WEB-INF/lib/jsr311-api-1.1.1.jar!/javax/ws/rs/ext/RuntimeDelegate.class

          [JENKINS-66837] java.lang.LinkageError due to the use of different version of the same library

          Florian CASTAGNO created issue -
          Florian CASTAGNO made changes -
          Summary Original: java.lang.LinkageError dur to the use of différent version of the same library New: java.lang.LinkageError dur to the use of different version of the same library
          Florian CASTAGNO made changes -
          Environment New: official docker image Jenkins 2.314
          jira-plugin 3.6
          gitlab-plugin 1.5.20
          Florian CASTAGNO made changes -
          Summary Original: java.lang.LinkageError dur to the use of different version of the same library New: java.lang.LinkageError due to the use of different version of the same library

          Sometimes, such conflicts are solved by implementing an API plugin and making both plugins depend on that.

          However, I wonder if would instead be possible to keep the classes used by the Jira and GitLab plugins separate from each other. Can you post the stack trace of the exception?

          Kalle Niemitalo added a comment - Sometimes, such conflicts are solved by implementing an API plugin and making both plugins depend on that. However, I wonder if would instead be possible to keep the classes used by the Jira and GitLab plugins separate from each other. Can you post the stack trace of the exception?

          Hello, Thanks for your response.

          The Stack trace bellow:

          [Pipeline] End of Pipeline
          java.lang.LinkageError: ClassCastException: attempting to castjar:file:/var/jenkins_home/plugins/gitlab-plugin/WEB-INF/lib/jboss-jaxrs-api_2.0_spec-1.0.0.Final.jar!/javax/ws/rs/ext/RuntimeDelegate.classtojar:file:/var/jenkins_home/plugins/jira/WEB-INF/lib/jsr311-api-1.1.1.jar!/javax/ws/rs/ext/RuntimeDelegate.class
          	at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:116)
          	at javax.ws.rs.ext.RuntimeDelegate.getInstance(RuntimeDelegate.java:91)
          	at javax.ws.rs.core.UriBuilder.newInstance(UriBuilder.java:69)
          	at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:80)
          	at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClient.<init>(AsynchronousJiraRestClient.java:58)
          	at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.create(AsynchronousJiraRestClientFactory.java:37)
          	at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.createWithBasicHttpAuthentication(AsynchronousJiraRestClientFactory.java:42)
          	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
          	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
          	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
          	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
          	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
          	at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:47)
          	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
          	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
          	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:141)
          	at jiraAddNextLabel.call(jiraAddNextLabel.groovy:30)
          	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
          	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
          	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
          	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
          	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
          	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:810)
          	at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:114)
          	at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1278)
          	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1138)
          	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
          	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:810)
          	at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:46)
          	at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1278)
          	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1172)
          	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
          	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
          	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
          	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
          	at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)
          	at pipelineAddNextLabel.call(pipelineAddNextLabel.groovy:19)
          	at ___cps.transform___(Native Method)
          	at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:86)
          	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:113)
          	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:83)
          	at jdk.internal.reflect.GeneratedMethodAccessor401.invoke(Unknown Source)
          	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
          	at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
          	at com.cloudbees.groovy.cps.impl.LocalVariableBlock$LocalVariable.get(LocalVariableBlock.java:39)
          	at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30)
          	at com.cloudbees.groovy.cps.impl.LocalVariableBlock.evalLValue(LocalVariableBlock.java:28)
          	at com.cloudbees.groovy.cps.LValueBlock$BlockImpl.eval(LValueBlock.java:55)
          	at com.cloudbees.groovy.cps.LValueBlock.eval(LValueBlock.java:16)
          	at com.cloudbees.groovy.cps.Next.step(Next.java:83)
          	at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
          	at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
          	at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129)
          	at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
          	at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
          	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
          	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
          	at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:185)
          	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:400)
          	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:96)
          	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:312)
          	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:276)
          	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
          	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
          	at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:139)
          	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
          	at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
          	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
          	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
          	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
          	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
          	at java.base/java.lang.Thread.run(Thread.java:829)
          Finished: FAILURE
          

          Florian CASTAGNO added a comment - Hello, Thanks for your response. The Stack trace bellow: [Pipeline] End of Pipeline java.lang.LinkageError: ClassCastException: attempting to castjar:file:/ var /jenkins_home/plugins/gitlab-plugin/WEB-INF/lib/jboss-jaxrs-api_2.0_spec-1.0.0.Final.jar!/javax/ws/rs/ext/RuntimeDelegate.classtojar:file:/ var /jenkins_home/plugins/jira/WEB-INF/lib/jsr311-api-1.1.1.jar!/javax/ws/rs/ext/RuntimeDelegate.class at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:116) at javax.ws.rs.ext.RuntimeDelegate.getInstance(RuntimeDelegate.java:91) at javax.ws.rs.core.UriBuilder.newInstance(UriBuilder.java:69) at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:80) at com.atlassian.jira. rest .client.internal.async.AsynchronousJiraRestClient.<init>(AsynchronousJiraRestClient.java:58) at com.atlassian.jira. rest .client.internal.async.AsynchronousJiraRestClientFactory.create(AsynchronousJiraRestClientFactory.java:37) at com.atlassian.jira. rest .client.internal.async.AsynchronousJiraRestClientFactory.createWithBasicHttpAuthentication(AsynchronousJiraRestClientFactory.java:42) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022) at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:47) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:141) at jiraAddNextLabel.call(jiraAddNextLabel.groovy:30) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:810) at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:114) at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1278) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1138) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:810) at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:46) at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1278) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1172) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20) at pipelineAddNextLabel.call(pipelineAddNextLabel.groovy:19) at ___cps.transform___(Native Method) at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:86) at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:113) at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:83) at jdk.internal.reflect.GeneratedMethodAccessor401.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72) at com.cloudbees.groovy.cps.impl.LocalVariableBlock$LocalVariable.get(LocalVariableBlock.java:39) at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30) at com.cloudbees.groovy.cps.impl.LocalVariableBlock.evalLValue(LocalVariableBlock.java:28) at com.cloudbees.groovy.cps.LValueBlock$BlockImpl.eval(LValueBlock.java:55) at com.cloudbees.groovy.cps.LValueBlock.eval(LValueBlock.java:16) at com.cloudbees.groovy.cps.Next.step(Next.java:83) at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174) at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163) at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129) at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268) at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51) at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:185) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:400) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:96) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:312) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:276) at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:139) at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28) at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang. Thread .run( Thread .java:829) Finished: FAILURE

          Kalle Niemitalo added a comment - - edited

          I presume RuntimeDelegate in jsr311-api-1.1.1.jar was compiled from https://github.com/javaee/jsr311/blob/jsr311-api-1.1.1/src/javax/ws/rs/ext/RuntimeDelegate.java, which deliberately throws LinkageError.

          RuntimeDelegate in jboss-jaxrs-api_2.0_spec-1.0.0.Final.jar may have been compiled from https://github.com/jboss/jboss-jaxrs-api_spec/blob/jboss-jaxrs-api_2.0_spec-1.0.0.Final/src/main/java/javax/ws/rs/ext/RuntimeDelegate.java.

          Both of these call FactoryFinder.find(JAXRS_RUNTIME_DELEGATE_PROPERTY, JAXRS_DEFAULT_RUNTIME_DELEGATE) to locate a RuntimeDelegate implementation by name. It might be possible to isolate these by making gitlab-api-plugin and jira-plugin temporary set a context class loader on the thread, but a new API plugin seems a more maintainable solution.

          Kalle Niemitalo added a comment - - edited I presume RuntimeDelegate in jsr311-api-1.1.1.jar was compiled from https://github.com/javaee/jsr311/blob/jsr311-api-1.1.1/src/javax/ws/rs/ext/RuntimeDelegate.java , which deliberately throws LinkageError. RuntimeDelegate in jboss-jaxrs-api_2.0_spec-1.0.0.Final.jar may have been compiled from https://github.com/jboss/jboss-jaxrs-api_spec/blob/jboss-jaxrs-api_2.0_spec-1.0.0.Final/src/main/java/javax/ws/rs/ext/RuntimeDelegate.java . Both of these call FactoryFinder.find(JAXRS_RUNTIME_DELEGATE_PROPERTY, JAXRS_DEFAULT_RUNTIME_DELEGATE) to locate a RuntimeDelegate implementation by name. It might be possible to isolate these by making gitlab-api-plugin and jira-plugin temporary set a context class loader on the thread, but a new API plugin seems a more maintainable solution.

          Kalle Niemitalo added a comment - - edited

          JENKINS-52171 seems to be the same problem with older plugin versions. JENKINS-60402 is also very similar but it applies to artifactory-plugin rather than jira-plugin.

          Kalle Niemitalo added a comment - - edited JENKINS-52171 seems to be the same problem with older plugin versions. JENKINS-60402 is also very similar but it applies to artifactory-plugin rather than jira-plugin.
          Kalle Niemitalo made changes -
          Link New: This issue duplicates JENKINS-52171 [ JENKINS-52171 ]
          Kalle Niemitalo made changes -
          Link New: This issue relates to JENKINS-60402 [ JENKINS-60402 ]

            baymac Parichay Barpanda
            florian_castagno Florian CASTAGNO
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: