Parsed allover the whole internet, but can\'t figure out why this happens. I\'ve got a simplest possible project (over jersey-quickstart-grizzly2 archetype) with one Jersey
Yes, in my opinion the answer above is correct. A very good way is to bridge Guice to HK2. I am not 100% sure if it neccessary to create a new TransportModule in the code above. Indeed Guice registers its injector in the ServletContext with the class name of Injector anyway, so it can be fetched from there:
register(new ContainerLifecycleListener() {
public void onStartup(Container container) {
ServletContainer servletContainer = (ServletContainer)container;
ServiceLocator serviceLocator = container.getApplicationHandler().getServiceLocator();
GuiceBridge.getGuiceBridge().initializeGuiceBridge(serviceLocator);
GuiceIntoHK2Bridge guiceBridge = serviceLocator.getService(GuiceIntoHK2Bridge.class);
Injector injector = (Injector) servletContainer.getServletContext().getAttribute(Injector.class.getName());
guiceBridge.bridgeGuiceInjector(injector);
}
public void onReload(Container container) {
}
public void onShutdown(Container container) {
}
});
Beside that it is not trivial how to configure the REST Endpoints in that way, so I wrote detailled blog about that here.