Open
Description
Using the latest version of Jersey-HK2, I have the following error when using an AbstractBinder
:
WARNING: The following warnings have been detected: WARNING: HK2 failure has been detected in a code that does not run in an active Jersey Error scope.
WARNING: Unknown HK2 failure detected:
MultiException stack 1 of 1
java.lang.NullPointerException: Cannot invoke "org.glassfish.jersey.server.internal.process.RequestProcessingContext.request()" because the return value of "org.glassfish.jersey.server.internal.process.RequestProcessingContextReference.get()" is null
at org.glassfish.jersey.server.internal.process.RequestProcessingConfigurator$ContainerRequestFactory.get(RequestProcessingConfigurator.java:67)
at org.glassfish.jersey.server.internal.process.RequestProcessingConfigurator$ContainerRequestFactory.get(RequestProcessingConfigurator.java:56)
at org.glassfish.jersey.inject.hk2.SupplierFactoryBridge.provide(SupplierFactoryBridge.java:76)
at org.jvnet.hk2.internal.FactoryCreator.create(FactoryCreator.java:129)
[...]
I was able to reproduce a minimal example in this repository https://github.com/amanteaux/jersey-grizzly-hk2-issue (starting from https://github.com/eclipse-ee4j/jersey/tree/3.1.9/examples/helloworld)
It is not very clear what triggers the error, using the exact binding described in my sample project triggers the error (but if the order changes or if a binding is deleted, the error disappeared).
I suspect the error is from HK2, but it could be Jersey as well.
Here are the bindings:
bindFactory(SessionFactory2.class).to(Session2.class).in(RequestScoped.class);
bindFactory(SessionFactory.class).to(InterfaceSession.class).in(RequestScoped.class);
bindFactory(SessionFactory.class).to(Session.class).in(RequestScoped.class);
Here is the factory:
public class SessionFactory implements Factory<Session> {
private final ContainerRequestContext context;
@Inject
public SessionFactory(ContainerRequestContext context) {
this.context = context;
}
@Override
public Session provide() {
return new Session(context.getHeaderString("Custom-Code"));
}
@Override
public void dispose(Session instance) {
}
}
Here is the resource definition:
@Path("helloworld")
public class HelloWorldResource {
@GET
@Path("/sample-response")
public String sampleResponse(@Context Session session) {
return "hello " + session.code();
}
@POST
@Path("/no-answer")
public void noAnswer(@Context Session session) {
System.out.println("no answer executed: " + session.code());
}
}
Metadata
Metadata
Assignees
Labels
No labels