title: How to handle jersey and tomcat errors consistently?
body: <p>I have implemented some (REST) service with jersey. If there is a bad request jersey handles the error and answers with some JSON content. There is an ExceptionMapper that should catch everything:</p>
  
  <pre><code>public class MyExceptionMapper implements ExceptionMapper&lt;Throwable&gt;
  </code></pre>
  
  <p>But if there is an invalid HTTP request - e.g. invalid content type - tomcat handles the exception before jersey has a chance to do so. The resulting response is some ugly tomcat HTML error page instead of the desired JSON.</p>
  
  <p>I know that it is possible to set an <code>&lt;error-page&gt;</code> in the deployment descriptor but there I have no access to any error details.</p>
  
  <p>Is there a way to prevent tomcat from catching this error? If so, jersey could catch it with its ExceptionMapper and return the correct response.</p>