I have a similar issue to the one raised here: How do I get my Jersey 2 Endpoints to eagerly initialize on startup?
But slightly further down the line. I can get my
One way to get a handle on the ServiceLocator
is to implement a Feature.
import javax.inject.Inject;
import javax.ws.rs.core.Feature;
import javax.ws.rs.core.FeatureContext;
import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.hk2.utilities.ServiceLocatorUtilities;
public class ImmediateFeature implements Feature {
@Inject
public ImmediateFeature(ServiceLocator locator) {
ServiceLocatorUtilities.enableImmediateScope(locator);
}
@Override
public boolean configure(FeatureContext context) {
return true;
}
}
Then just register the Feature
ResourceConfig rc = new ResourceConfig().packages("jersey.hk2.test");
rc.register(ImmediateFeature.class);
I've tested this and it works fine