Version compatability

Hi All, I am getting below error while running a job in jenkins. any help on this is very much appreciated.
java.lang.ClassCastException: Cannot cast org.glassfish.jersey.inject.hk2.Hk2InjectionManagerFactory to org.glassfish.jersey.internal.inject.InjectionManagerFactory
at java.base/java.lang.Class.cast(Class.java:3605)
at org.glassfish.jersey.internal.ServiceFinder$LazyObjectIterator.hasNext(ServiceFinder.java:690)
at org.glassfish.jersey.internal.inject.Injections.lookupService(Injections.java:101)
at org.glassfish.jersey.internal.inject.Injections.lookupInjectionManagerFactory(Injections.java:85)
at org.glassfish.jersey.internal.inject.Injections.createInjectionManager(Injections.java:56)
at org.glassfish.jersey.client.ClientConfig$State.findInjectionManager(ClientConfig.java:477)
at org.glassfish.jersey.client.ClientConfig$State.initRuntime(ClientConfig.java:414)
at org.glassfish.jersey.internal.util.collection.Values$LazyValueImpl.get(Values.java:317)
at org.glassfish.jersey.client.ClientConfig.getRuntime(ClientConfig.java:829)
at org.glassfish.jersey.client.ClientRequest.getClientRuntime(ClientRequest.java:176)
at org.glassfish.jersey.client.JerseyWebTarget.onBuilder(JerseyWebTarget.java:371)
at org.glassfish.jersey.client.JerseyWebTarget.request(JerseyWebTarget.java:199)
at org.glassfish.jersey.client.JerseyWebTarget.request(JerseyWebTarget.java:38)
at org.gitlab4j.api.GitLabApiClient.invocation(GitLabApiClient.java:837)
at org.gitlab4j.api.GitLabApiClient.invocation(GitLabApiClient.java:801)
at org.gitlab4j.api.GitLabApiClient.get(GitLabApiClient.java:416)
at org.gitlab4j.api.GitLabApiClient.get(GitLabApiClient.java:404)
at org.gitlab4j.api.AbstractApi.get(AbstractApi.java:214)
Caused: org.gitlab4j.api.GitLabApiException: Cannot cast org.glassfish.jersey.inject.hk2.Hk2InjectionManagerFactory to org.glassfish.jersey.internal.inject.InjectionManagerFactory
at org.gitlab4j.api.AbstractApi.handle(AbstractApi.java:700)
at org.gitlab4j.api.AbstractApi.get(AbstractApi.java:216)
at org.gitlab4j.api.RepositoryApi.getBranch(RepositoryApi.java:110)
at io.jenkins.plugins.gitlabbranchsource.GitLabSCMSource.retrieve(GitLabSCMSource.java:268)
at jenkins.scm.api.SCMSource.fetch(SCMSource.java:581)
at org.jenkinsci.plugins.workflow.multibranch.SCMVar.getValue(SCMVar.java:104)
at org.jenkinsci.plugins.workflow.multibranch.SCMVar.getValue(SCMVar.java:59)
at org.jenkinsci.plugins.workflow.cps.CpsScript.getProperty(CpsScript.java:137)
at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:190)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:469)
at org.kohsuke.groovy.sandbox.impl.Checker$7.call(Checker.java:377)
at org.kohsuke.groovy.sandbox.GroovyInterceptor.onGetProperty(GroovyInterceptor.java:68)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:347)
at org.kohsuke.groovy.sandbox.impl.Checker$7.call(Checker.java:375)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:379)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:355)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:355)
at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:29)
at org.jenkinsci.plugins.workflow.cps.LoggingInvoker.getProperty(LoggingInvoker.java:121)
at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
Also: org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: 9a1183a7-843d-46c5-a46a-caa50882ab87
Caused: java.io.IOException: Failed to retrieve the SCM revision for main
at io.jenkins.plugins.gitlabbranchsource.GitLabSCMSource.retrieve(GitLabSCMSource.java:312)
at jenkins.scm.api.SCMSource.fetch(SCMSource.java:581)
at org.jenkinsci.plugins.workflow.multibranch.SCMVar.getValue(SCMVar.java:104)
at org.jenkinsci.plugins.workflow.multibranch.SCMVar.getValue(SCMVar.java:59)
at org.jenkinsci.plugins.workflow.cps.CpsScript.getProperty(CpsScript.java:137)
at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:190)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:469)
at org.kohsuke.groovy.sandbox.impl.Checker$7.call(Checker.java:377)
at org.kohsuke.groovy.sandbox.GroovyInterceptor.onGetProperty(GroovyInterceptor.java:68)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:347)
at org.kohsuke.groovy.sandbox.impl.Checker$7.call(Checker.java:375)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:379)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:355)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:355)
at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:29)
at org.jenkinsci.plugins.workflow.cps.LoggingInvoker.getProperty(LoggingInvoker.java:121)
at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
at WorkflowScript.run(WorkflowScript:18)
at cps.transform(Native Method)
at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.get(PropertyishBlock.java:73)
at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30)
at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.fixName(PropertyishBlock.java:65)
at jdk.internal.reflect.GeneratedMethodAccessor211.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.ConstantBlock.eval(ConstantBlock.java:21)
at com.cloudbees.groovy.cps.Next.step(Next.java:83)
at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:152)
at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:146)
at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:136)
at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:275)
at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:146)
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:187)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:423)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:331)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:295)
at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:97)
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 jenkins.util.ErrorLoggingExecutorService.lambda$wrap$0(ErrorLoggingExecutorService.java:51)
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

Thank you

Hello @rkjeevan and welcome to this community. :wave:

It looks to me that an attempt was made to cast an object to a type that it is not instance of. :person_shrugging:
org.glassfish.jersey.inject.hk2.Hk2InjectionManagerFactory cannot be cast to org.glassfish.jersey.internal.inject.InjectionManagerFactory.

This issue is sometimes caused by having multiple versions of the same library in the classpath. In this case, it seems like there might be conflicting versions of the org.glassfish.jersey library.

Hi @poddingue : Thank you for the reply. Could you help me how/where to check this ? Also, if that is the case how do i fix it? I am sorry, i am new to this.
Any help is appreciated.

Thank you

You could start with mvn -U dependency:tree and see if you have different versions listed if you’re using Maven.

Jersey 2 API Version 2.38-1]- old jenkins instance
Jersey 2 API Version 2.41-133.va[_03323b_a_1396] - new jenkins instance
the issue we are facing is when we run jobs on new jenkins instance, where the same job runs just fine on old jenkins instance