I created a basic application shell with AppFuse, and followed the AppFuse tutorial to create a a simple RESTful service with Jax-RS. That works just fine. A call to
Adding it to the method signature worked. I imagine it's because the request and response objects don't yet exist when the class is instantiated, but does when called by the brower.
@Path("/")
@GET
@Produces(MediaType.APPLICATION_JSON)
List<Person> read( @Context HttpServletRequest httpServletRequest, @Context HttpServletResponse httpServletResponse) { }
Try injecting the HttpServletRequest
and HttpServletContext
directly:
@Context private HttpServletRequest servletRequest;
@Context private HttpServletContext servletContext;