Injecting HttpRequest in RESTEasy Reactive / Quarkus fails

I’m currently trying to inject and read out the HttpRequest in Quarkus 1.13 but without any success. I’m using RESTEasy-Reactive for my endpoint.

This is how I’m currently including it

class UserController(
    @Inject val service: UserService,
    @Context val httpRequest: io.vertx.core.http.HttpServerRequest,

The build process succeeds but when I try to access a property like httpRequest.absoluteURI() I am getting an NPE

java.lang.NullPointerException: Cannot invoke "org.jboss.resteasy.reactive.server.core.ResteasyReactiveRequestContext.serverRequest()" because the return value of "org.jboss.resteasy.reactive.server.core.CurrentRequestManager.get()" is null
    at io.quarkus.resteasy.reactive.server.runtime.QuarkusContextProducers.httpServerRequest(
    at io.quarkus.resteasy.reactive.server.runtime.QuarkusContextProducers_Subclass.httpServerRequest$$superaccessor3(QuarkusContextProducers_Subclass.zig:451)
    at io.quarkus.resteasy.reactive.server.runtime.QuarkusContextProducers_Subclass$$function$$3.apply(QuarkusContextProducers_Subclass$$function$$3.zig:29)

I also tried other classes like io.vertx.mutiny.core.http.HttpServerRequest or but still without success. Injecting it with @Inject didn’t even build. I’m missing the HttpServletRequest class :/

Anybody got an idea?


You have a few options:

Using HttpFilter:

@WebFilter(urlPatterns = "/*")
public class FilterEverything extends HttpFilter {

    protected void doFilter(HttpServletRequest req, HttpServletResponse res, FilterChain chain) throws IOException, ServletException {

        //Do something with HttpServletRequest 


Using ContainerRequestFilter:

As Quarkus Documentation Showcases:

public class LoggingFilter implements ContainerRequestFilter {

    private static final Logger LOG = Logger.getLogger(LoggingFilter.class);

    UriInfo info;

    HttpServerRequest request;

    public void filter(ContainerRequestContext context) {

        //Do whatever you want

As part of the method signature:

public JsonObject getData(@PathParam("owner") String owner, @Context HttpServletRequest request) {
   //Do something here