Skip to content
This repository has been archived by the owner on Jan 31, 2019. It is now read-only.

It appears jersey2-guice-spi is either not present or in conflict with some other Jar #38

Open
xinranxiao opened this issue May 23, 2016 · 4 comments

Comments

@xinranxiao
Copy link

I'm trying to use this package with Dropwizard and Guice, using the "complex example" code in the wiki of this repo. I'm currently getting this error when I start my application

.... It appears jersey2-guice-spi is either not present or in conflict with some other Jar: ServiceLocatorGeneratorImpl(hk2-locator, 1911168986)

It looks like this is related to this (#37)... I did some monkeypatching with JerseyGuiceUtils.java and printed out the names of the providers within lookupSPI:

for (ServiceLocatorGenerator generator : providers) {
  System.out.println(generator.getClass().getName());
}

And I get:

org.jvnet.hk2.external.generator.ServiceLocatorGeneratorImpl
com.squarespace.jersey2.guice.GuiceServiceLocatorGeneratorStub
org.jvnet.hk2.external.generator.ServiceLocatorGeneratorImpl

Currently the code just takes the first one... however it looks like the second one is the right class. Would it be better to just loop over the providers and check all of them?

@rkapsi
Copy link
Contributor

rkapsi commented May 23, 2016

@xinranxiao yea it seems something is initializing Jersey before you do. Are you initializing jersey2-guice straight from the main() method or as early as possible and definitively before DW which will trip Jersey.

Secondly I'd look at the classpath and the order in which JARs are being loaded. The jersey2-guice-spi JAR is purposely called 0-jersey2-guice-spi to move it to the front (but there may be no guarantee). But this is optional and it should work if initialization happens in the main() method.

@tmwilder
Copy link

tmwilder commented Sep 21, 2017

Came here from dropwizard-guice - also encountering what looks like the same issue.

I'm seeing:

WARN [2017-09-21 16:41:23,236] com.squarespace.jersey2.guice.JerseyGuiceUtils: It appears jersey2-guice-spi is either not present or in conflict with some other Jar: ServiceLocatorGeneratorImpl(hk2-locator, 832648870) Exception in thread "main" java.lang.LinkageError: loader (instance of sun/misc/Launcher$AppClassLoader): attempted duplicate class definition for name: "org/glassfish/hk2/api/ServiceLocatorState" at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:760) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) at java.net.URLClassLoader.access$100(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:368) at java.net.URLClassLoader$1.run(URLClassLoader.java:362) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:361) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at org.jvnet.hk2.internal.ServiceLocatorImpl.<init>(ServiceLocatorImpl.java:207) at com.squarespace.jersey2.guice.GuiceServiceLocator.<init>(GuiceServiceLocator.java:29) at com.squarespace.jersey2.guice.JerseyGuiceUtils.newServiceLocator(JerseyGuiceUtils.java:248) at com.squarespace.jersey2.guice.JerseyGuiceUtils.newServiceLocator(JerseyGuiceUtils.java:227) at com.squarespace.jersey2.guice.JerseyGuiceUtils.newServiceLocator(JerseyGuiceUtils.java:220) at com.hubspot.dropwizard.guice.GuiceBundle.initialize(GuiceBundle.java:126)

@jessechahal
Copy link

This issue hasn't seen a real update for over 2 years. Is this project currently dead/inactive? I'm seeing the same issue when trying to using dropwizard-guice and swagger2.0. Both use this automated way of discovering resources.

@rkapsi
Copy link
Contributor

rkapsi commented Jun 21, 2018

Hello, the project is currently inactive. We don't have any Jersey 2 w/ Guice projects.

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

No branches or pull requests

4 participants