I'm trying to test a resource with Resteasy using an embedded Netty instance as described in the Resteasy Docs.
Injecting path parameters and query parameters works like a charm but then I tried to test a resource that injects HttpServletRequest and HttpServletResponse from the context like this:

@GET@Path("/")public void example(@Context HttpServletResponse response, @Context HttpServletRequest request) { ... }Resteasy cannot find HttpServletRequestin the context and throws the following exception:

5105 [r #1] DEB o.j.resteasy.core.SynchronousDispatcher - PathInfo: /auth5201 [r #1] ERR c.s.f.v.s.r.e.ApplicationExceptionMapper - Unhandled application exception: Unable to find contextual data of type: javax.servlet.http.HttpServletRequestorg.jboss.res teasy.spi.LoggableFailure: Unable to find contextual data of type: javax.servlet.http.HttpServletRequestI tried putting mock versions of request and response in the context as suggested in this [question] (RESTEasy Mock vs. Exception Mapper vs. Context) but it does not work either as the contextual data is a ThreadLocal and Netty spawns a new thread for each request.
Any ideas on how to solve this?

Check Solution