HubSpot / dropwizard-guice

Adds support for Guice to Dropwizard
Apache License 2.0
266 stars 95 forks source link

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

Closed psvanstrom closed 8 years ago

psvanstrom commented 8 years ago

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?

JanMosigItemis commented 8 years ago

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?

vmd408 commented 8 years ago

I'm facing this issue too.

jcolaco-nmz commented 8 years ago

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

ruipinge commented 8 years ago

+1

jdduarte commented 8 years ago

+1

jhaber commented 8 years ago

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

ruipinge commented 8 years ago

@jhaber,

You're talking about this commit right? 5b2e3357fc23e368ec9e3b6a484147e7196b0ef7

Cheers

jhaber commented 8 years ago

Yep

vmd408 commented 8 years ago

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!

jcolaco-nmz commented 8 years ago

Yup, it fixes it. Thank you 👍

jhaber commented 8 years ago

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

tmwilder commented 7 years ago

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

OndraZizka commented 6 years ago

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

hithwen commented 6 years ago

I'm seeing this with dropwizard-guice 1.0.6.0