The HK2 Guice Bridge is available, but there may be more work needed in Jersey in order to enable it.
Ability to inject ServletContext into Application constructor
Implement Spring integration for Jersey 2
@Hk2Inject does not work on the constructors of Guice services
This issue is related to https://java.net/jira/browse/HK2-39 and https://java.net/jira/browse/HK2-121
To reiterate, here is what we had in Jersey 1.0:
\-> GuiceFilter (Guice: initialize request scope)
\-> GuiceServletContextListener (Guice: initialize the Guice injector)
\-> JerseyServletModule (Jersey: bind Jersey types to Guice module)
\-> GuiceContainer (Jersey: redirect incoming requests to resource classes)
In other words, we created a Guice injector first and initialized Jersey second.
In Jersey 2.0 we have a circular reference. We need to initialize Injector before ServletContainer (otherwise @RequestScoped isn't initialized), but we need to initialize ServletContainer before Injector (otherwise we can't get a reference to ServiceLocator).
I've voted for this, but I also wanted to comment that because of this issue alone, I may be forced to switch to another JAX-RS provider (namely RESTEasy, which works quite well with Guice, thank you very much). Obviously I'd rather not do that, but HK2 is really getting in my way.
@jitterted i was able to get things working by following this HK2 comment. It's not great, but should work until the Jersey guys finally get around to tackling this issue
I too, after many happy years of Jersey use, had to switch to RESTeasy over this issue
I start to feel you pain over this issue. I have a large code base that dependes on jersey 1.x and can't simple switch to Resteasy.
As long as the support for Guice in Jersey 2.x is so cumbersome, I myself will not be willing to switch to Jersey 2. Using/handling one DI framework is enough, using two DI frameworks is pointing towards spaghetti.