Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-396

Unable to inject contextual data of type: javax.ws.rs.core.HttpHeaders

    XMLWordPrintable

Details

    Description

      I created an ExeptionMapper :
      @Provider
      public class NotFoundExceptionMapper implements ExceptionMapper<NotFoundException> {

      private static final Logger LOG = Logger.getLogger(NotFoundExceptionMapper.class);
      @Context
      HttpHeaders httpHeaders;

      /*

      • (non-Javadoc)
      • @see javax.ws.rs.ext.ExceptionMapper#toResponse(java.lang.Throwable)
        */
        @Override
        public Response toResponse(final NotFoundException exception) { // TODO add to docs: INTERNAL_SERVER_ERROR LOG.error("Exception is being handled by NotFoundExceptionMapper"); LOG.error(exception.getMessage()); return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).type(httpHeaders.getMediaType().toString()).build(); }

        }

      When I try to access non-existant url I got the following stacktrace :
      SEVERE: Servlet.service() for servlet Resteasy threw exception
      org.jboss.resteasy.spi.LoggableFailure: Unable to inject contextual data of type: javax.ws.rs.core.HttpHeaders
      at org.jboss.resteasy.core.ContextParameterInjector$GenericDelegatingProxy.invoke(ContextParameterInjector.java:53)
      at $Proxy16.getRequestHeader(Unknown Source)

      Attachments

        Issue Links

          Activity

            People

              patriot1burke@gmail.com Bill Burke (Inactive)
              pmilczar_jira Piotr Milczarek (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: