title: Obtaining raw request body in JAX-RS resource method
body: <p>How can I access the raw request body from a JAX-RS resource method, as <code>java.io.InputStream</code> or <code>byte[]</code>? I want the container to bypass any <code>MessageBodyReader</code> for a specific resource class or method, but I have other resources in the projects which should be using some <code>MessageBodyReader</code>.</p>
  
  <p>I have tried this, but it will invoke registered <code>MessageBodyReader</code>s and fail to assign the result to <code>InputStream</code> (same issue with <code>byte[]</code>).</p>
  
  <pre><code>@POST
  public Response post(@Context HttpHeaders headers, InputStream requestBody) {
      MediaType contentType = headers.getMediaType();
      // ... 
  }
  </code></pre>
  
  <p>I have also tried this, but then the container fails to initialize with this error:</p>
  
  <pre>
  SEVERE: The following errors and warnings have been detected with resource and/or provider classes:
  SEVERE: Missing dependency for method public javax.ws.rs.core.Response SomeResource.post(javax.servlet.http.HttpServletRequest) at parameter at index 0
  SEVERE: Method, public javax.ws.rs.core.Response SomeResource.post(javax.servlet.http.HttpServletRequest), annotated with POST of resource, class SomeResource, is not recognized as valid resource method.
  </pre>
  
  <pre><code>@POST
  public Response post(@Context HttpServletRequest request) {
      String contentType = request.getContentType();
      InputStream requestBody = request.getInputStream();
      // ... 
  }
  </code></pre>
  
  <p>The method is in a sub resource class, which is created from a method with a <code>@Path</code> annotation in another resource class.</p>
  
  <p>I am using Jersey 1.11.</p>