[jax-rs-spec users] ExceptionMapper for ConstraintViolationException

From: Christian Kaltepoth <>
Date: Wed, 15 Apr 2015 07:21:00 +0200

Hey all,

I've a question for you.

Imagine a resource class which uses Bean Validation annotations for
defining constraints. See this example:

Does the spec require that a user should be able to define a custom
ExceptionMapper for ConstraintViolationExceptions to handle validation
failures? See this ExceptionMapper as an example:

I'm asking this because the scenario described above doesn't work in
RESTEasy. It looks like RESTEasy throws some custom exception type instead
of the raw ConstraintViolationException which basically means that the
ExceptionMapper isn't applied.

The relevant sentences from the spec are:

   - Section 7.6: JAX-RS implementations MUST provide a default exception
   mapper [...] for javax.validation.ValidationException [...]
   - Section 7.6: [...] applications can provide their own exception
   mappers and, consequently, customize the default mapper described above.
   - Section 4.4: When choosing an exception mapping provider to map an
   exception, an implementation MUST use the provider whose generic type is
   the nearest superclass of the exception.

However, there is IMO nothing in the spec requiring that the JAX-RS
implementation throws the raw Bean Validation exception type.

Any thoughts on this?


PS: You will find the example application which is deployable to any
JavaEE7 compatible container here:

Christian Kaltepoth