title: HK2InjectionManager with jersey, upgrading with OpenJDK11
body: <p>Ran into a few errors as I am upgrading jdk11 and jersey but this one particularly stumped. So jersey 2.28 is supposedly compatible with OpenJDK11 and fixed some issues that was previously in 2.25.1, so I upgraded it</p>
  
  <p>I also saw this already, not a working solution - <a href="https://stackoverflow.com/questions/47170830/jersey-spring-maven-java-lang-noclassdeffounderror-org-glassfish-jersey-hk2-hk2">Jersey Spring Maven java.lang.NoClassDefFoundError: org/glassfish/jersey/hk2/HK2InjectionManager</a></p>
  
  <p>In my gradle build, failed on this task:</p>
  
  <p><code>&gt; Task :ods-impl:test FAILED</code></p>
  
  <p>Under my task for this, here is the list of dependencies</p>
  
  <pre><code>    compile group: 'org.glassfish.jersey.containers', name: 'jersey-container-servlet', version: '2.28'
      compile group: 'org.glassfish.jersey.ext', name: 'jersey-spring3', version: '2.26-b03'
      compile group: 'org.glassfish.jersey.media', name: 'jersey-media-json-jackson', version: '2.28'
      compile group: 'org.glassfish.jersey.media', name: 'jersey-media-multipart', version: '2.28'
      compile group: 'commons-lang', name: 'commons-lang', version: property('rev.commons-lang')
  </code></pre>
  
  <p>So then I encountered a new error with </p>
  
  <pre><code>java.lang.NoClassDefFoundError: org/glassfish/jersey/hk2/HK2InjectionManager
  
      at org.glassfish.jersey.server.spring.SpringComponentProvider.initialize(SpringComponentProvider.java:112)
      at org.glassfish.jersey.server.ComponentProviderConfigurator.lambda$null$0(ComponentProviderConfigurator.java:55)
      at java.base/java.util.stream.ReferencePipeline$11$1.accept(ReferencePipeline.java:441)
      at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
      at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1654)
      at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
      at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
      at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
      at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
      at org.glassfish.jersey.server.ComponentProviderConfigurator.lambda$init$1(ComponentProviderConfigurator.java:56)
      at org.glassfish.jersey.internal.util.collection.Values$LazyValueImpl.get(Values.java:317)
      at org.glassfish.jersey.server.ResourceModelConfigurator.bindProvidersAndResources(ResourceModelConfigurator.java:111)
      at org.glassfish.jersey.server.ResourceModelConfigurator.init(ResourceModelConfigurator.java:63)
      at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:341)
      at org.glassfish.jersey.server.ApplicationHandler.lambda$initialize$1(ApplicationHandler.java:292)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
      at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:232)
      at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:291)
      at org.glassfish.jersey.server.ApplicationHandler.&lt;init&gt;(ApplicationHandler.java:258)
      at org.glassfish.jersey.server.ApplicationHandler.&lt;init&gt;(ApplicationHandler.java:245)
      at org.glassfish.jersey.jetty.JettyHttpContainer.&lt;init&gt;(JettyHttpContainer.java:445)
      at org.glassfish.jersey.jetty.JettyHttpContainerProvider.createContainer(JettyHttpContainerProvider.java:37)
      at org.glassfish.jersey.server.ContainerFactory.createContainer(ContainerFactory.java:58)
      at org.glassfish.jersey.jetty.JettyHttpContainerFactory.createServer(JettyHttpContainerFactory.java:135)
      at org.glassfish.jersey.test.jetty.JettyTestContainerFactory$JettyTestContainer.&lt;init&gt;(JettyTestContainerFactory.java:68)
      at org.glassfish.jersey.test.jetty.JettyTestContainerFactory$JettyTestContainer.&lt;init&gt;(JettyTestContainerFactory.java:45)
      at org.glassfish.jersey.test.jetty.JettyTestContainerFactory.create(JettyTestContainerFactory.java:126)
      at org.glassfish.jersey.test.JerseyTest.createTestContainer(JerseyTest.java:254)
      at org.glassfish.jersey.test.JerseyTest.setUp(JerseyTest.java:584)
      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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
      at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
      at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
      at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
  Caused by: java.lang.ClassNotFoundException: org.glassfish.jersey.hk2.HK2InjectionManager
      at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
      at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
      at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
      ... 54 more
  </code></pre>
  
  <p>So I added this dependency:</p>
  
  <pre><code>compile group: 'org.glassfish.jersey.inject', name: 'jersey-hk2', version: '2.28'
  </code></pre>
  
  <p>However, I am still encountering that same error message, is there something wrong with how the dependencies matches up? I see it resolved the hk2 here in IntelliJ</p>
  
  <p><a href="https://i.stack.imgur.com/FIuMZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FIuMZ.png" alt="enter image description here"></a></p>
  
  <p>Further digging I noticed that HK2InjectionManager on SpringComponentProvider is importing from the wrong path versus the location from the Hk2 dependency</p>
  
  <p>Correct path from Jersey:
  import org.glassfish.jersey.inject.hk2.Hk2InjectionManagerFactory;</p>
  
  <p>Path from Spring:
  import org.glassfish.jersey.hk2.HK2InjectionManager;</p>