ExceptionMapper not working consistently in Jersey 2.x & javax
<p>I am using <code>javax and jersey</code> for my api application (exposing api endpoints)
I am trying to catch exceptions coming from fasterXml (on put and post calls) by having a Provider which implements ExceptionMapper.</p>

<p>My Problem is that on POST or PUT, whenever I am sending wrong attributes names, sometime my mapper catch the exceptions and sometime it doesn't.
For example:</p>

<ol>
<li><p>Running my application once -> everything is working as expected, catching exceptions.</p></li>
<li><p>Running my application again (restart) -> the mapper does not catch nothing</p></li>
</ol>

<p>I am using Jersey 2.x, hosting in tomcat (not using spring or anything like that). </p>

<p>web.xml:</p>

<pre><code>&lt;servlet&gt;
    &lt;servlet-name&gt;api-service-endpoints&lt;/servlet-name&gt;
    &lt;servlet-class&gt;org.glassfish.jersey.servlet.ServletContainer&lt;/servlet-class&gt;
    &lt;init-param&gt;
        &lt;param-name&gt;jersey.config.server.provider.packages&lt;/param-name&gt;
        &lt;param-value&gt;
            com.api.providers,
            com.api.resources
        &lt;/param-value&gt;

    &lt;/init-param&gt;
    &lt;init-param&gt;
        &lt;param-name&gt;jersey.config.server.provider.classnames&lt;/param-name&gt;
        &lt;param-value&gt;org.glassfish.jersey.filter.LoggingFilter&lt;/param-value&gt;
    &lt;/init-param&gt;
    &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
&lt;/servlet&gt;
</code></pre>

<p>Provider Code:</p>

<pre><code>@Provider
public class JsonMappingExceptionProvider
    implements ExceptionMapper&lt;JsonMappingException&gt; {

public JsonMappingExceptionProvider() {
    log.info("JsonMappingExceptionProvider created..");
}

private static final Logger log = LoggerFactory
        .getLogger(JsonMappingExceptionProvider.class);

@Override
public Response toResponse(JsonMappingException exception) {
    log.error("Error while parsing input", exception);
    Response response = createBadRequestResponse();
    return response;
}
</code></pre>

<p>Any ideas? </p>