-
Bug
-
Resolution: Unresolved
-
Major
-
Jenkins LTS 2.190.1
CentOS 7.6
GitLabAPI Plugin 1.0.5
Artifactory Plugin 3.4.1
I am trying to use the gitlab API library provided by the gitlab-api-plugin in a custom pipeline library that gets loaded globally.
The pipeline code looks like this:
import org.gitlab4j.api.GitLabApi import org.gitlab4j.api.models.Branch import org.gitlab4j.api.GitLabApiException boolean isProtected() { String project = 'theproject' String branch = 'thebranch' def gitlabApi = null boolean ret = false withCredentials([usernamePassword(credentialsId: 'someid-1234-1234', usernameVariable: 'UNUSED_USERNAME', passwordVariable: 'GITLAB_APITOKEN')]) { gitlabApi = new GitLabApi('https://gitlab.example.com', GITLAB_APITOKEN) } if (gitlabApi) { def glBranch = gitlabApi.getRepositoryApi().getBranch(project, branch) ret = glBranch.getProtected() } return ret }
The method gets called in a Jenkinsfile which then results in the following stacktrace:
java.lang.LinkageError: ClassCastException: attempting to castjar:file:/data/jenkins/plugins/artifactory/WEB-INF/lib/javax.ws.rs-api-2.1.jar!/javax/ws/rs/ext/RuntimeDelegate.class to jar:file:/data/jenkins/plugins/gitlab-api/WEB-INF/lib/jakarta.ws.rs-api-2.1.6.jar!/javax/ws/rs/ext/RuntimeDelegate.class at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:124) at javax.ws.rs.ext.RuntimeDelegate.getInstance(RuntimeDelegate.java:96) at javax.ws.rs.core.UriBuilder.newInstance(UriBuilder.java:72) at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:96) at org.glassfish.jersey.client.JerseyWebTarget.<init>(JerseyWebTarget.java:48) at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:274) at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:56) at org.gitlab4j.api.GitLabApiClient.invocation(GitLabApiClient.java:749) at org.gitlab4j.api.GitLabApiClient.invocation(GitLabApiClient.java:723) at org.gitlab4j.api.GitLabApiClient.get(GitLabApiClient.java:389) at org.gitlab4j.api.GitLabApiClient.get(GitLabApiClient.java:377) at org.gitlab4j.api.AbstractApi.get(AbstractApi.java:213) at org.gitlab4j.api.RepositoryApi.getBranch(RepositoryApi.java:104) 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.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 com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20) at branch.isProtected(branch.groovy:31) at WorkflowScript.run(WorkflowScript:54) at com.fabasoft.pipeline.Utils.globalWrapper(Utils.groovy:1091) at com.fabasoft.pipeline.Utils.gitlabStatus(Utils.groovy:1068) 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 sun.reflect.GeneratedMethodAccessor181.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) 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:186) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:370) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:93) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:282) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:270) at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131) at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28) at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59) 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:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
As I found similar Issues with other plugin combinations I tried to build the plugin myself and set the following maven options for the build:
<build> <plugins> <plugin> <groupId>org.jenkins-ci.tools</groupId> <artifactId>maven-hpi-plugin</artifactId> <configuration> <pluginFirstClassLoader>true</pluginFirstClassLoader> </configuration> </plugin> </plugins> </build>
But this does not seem to work for plugins that only provide a library (as dependency) and do not contain any code themself.
- relates to
-
JENKINS-66837 java.lang.LinkageError due to the use of different version of the same library
- Open