dropwizard-guice icon indicating copy to clipboard operation
dropwizard-guice copied to clipboard

Getting a warning at startup: "It appears jersey2-guice-spi is either not present or in conflict with some other Jar"

Open psvanstrom opened this issue 10 years ago • 14 comments

I'm getting a WARN in my log at startup:

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

Is this to be expected? I can see that the GuiceBundle.java explicitly loads the HK2 ServiceLocator which is what makes the JerseyGuiceUtils complain:

https://github.com/HubSpot/dropwizard-guice/blob/master/src/main/java/com/hubspot/dropwizard/guice/GuiceBundle.java#L104-L111

Everything seems to work alright but still it's a bit annoying having a WARN in the startup log so I just to make sure that this is ok?

psvanstrom avatar Aug 25 '16 08:08 psvanstrom

I did also encounter this kind of issue and its really annoying. Is there something that can be done about this? Why does the GuiceBundle force the HK2 ServiceLocator?

JanMosigItemis avatar Sep 13 '16 11:09 JanMosigItemis

I'm facing this issue too.

vmd408 avatar Sep 21 '16 08:09 vmd408

I'm facing this issue too. I'm also wondering if this is the cause for other problem I'm having:

com.google.inject.OutOfScopeException: Cannot access scoped [javax.servlet.http.HttpServletRequest]

Both only appeared after upgrading to dropwizard 1.0.0 and dropwizard-guice 1.0.0.1

jcolaco-nmz avatar Sep 23 '16 13:09 jcolaco-nmz

+1

ruipinge avatar Sep 23 '16 13:09 ruipinge

+1

jdduarte avatar Sep 23 '16 13:09 jdduarte

I'm not sure how if there's a robust way to avoid this. Looking at the jersey2-guice code, it seems like it logs this warning when the first ServiceLocatorGenerator returned from the ServiceLoader isn't an instance of GuiceServiceLocatorGeneratorStub. In this case, it seems to be an instance of ServiceLocatorGeneratorImpl from the hk2-locator artifact. I tried excluding that artifact but that doesn't work because JerseyGuiceUtils references other hk2-locator classes directly so I get a ClassNotFoundException. I was able to sort of hack around this problem in my test application by moving the jersey2-guice-impl dependency to the front of the list, which made the warning stop printing. Can anyone experiencing this issue try running your app against this commit to see if it fixes it for you as well? If so, I'll cut a release with this change

jhaber avatar Sep 23 '16 22:09 jhaber

@jhaber,

You're talking about this commit right? 5b2e3357fc23e368ec9e3b6a484147e7196b0ef7

Cheers

ruipinge avatar Sep 26 '16 09:09 ruipinge

Yep

jhaber avatar Sep 26 '16 12:09 jhaber

Can anyone experiencing this issue try running your app against this commit to see if it fixes it for you as well?

Confirm. Thank you for the effort!

vmd408 avatar Sep 26 '16 13:09 vmd408

Yup, it fixes it. Thank you 👍

jcolaco-nmz avatar Sep 27 '16 15:09 jcolaco-nmz

Thanks for confirmation, I just released this change as part of version 1.0.0.2 which should show up in Maven central soon

jhaber avatar Sep 30 '16 22:09 jhaber

I'm currently experiencing this issue on dropwizard-guice 1.0.0.2.

tmwilder avatar Sep 21 '17 21:09 tmwilder

I am seeing this with DropWizard 1.3.1. We had to downgrade HK2 because injection to @BeanParam stopped working.

OndraZizka avatar Jun 06 '18 11:06 OndraZizka

I'm seeing this with dropwizard-guice 1.0.6.0

hithwen avatar Oct 30 '18 05:10 hithwen