-
Notifications
You must be signed in to change notification settings - Fork 571
Closed
Labels
Description
Hi,
HttpServletRequest injection into the ExceptionMapper is not working for an application using AWS JerseyLambdaContainerHandler.
Is there a way that I can get hold of request in the ExceptionMapper ?
import java.util.Arrays;
import java.util.NoSuchElementException;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Provider
public class NoSuchElementMapper implements ExceptionMapper {
@context private HttpServletRequest request;
@Override
public Response toResponse(NoSuchElementException exception) {
LOG.debug("request:" + (request != null));
Response.Status statusCode = Response.Status.NOT_FOUND;
return Response.status(statusCode).entity(exception.getMessage())
.type(MediaType.TEXT_PLAIN)
.build();
}
}