@Marek & @Santiago:
Thanks for the confirmation. I ran into this during some early experiments
regarding the validation support for MVC 1.0. I was just wondering whether
the RESTEasy behavior is "allowed" according to the spec.
@Willem:
Thanks for the link. I added a reference to this thread to the issue.
Christian
2015-04-15 15:27 GMT+02:00 Willem Salembier <willem.salembier_at_gmail.com>:
> Hi Christian,
>
> The behavior you describe is logged as bug in RESTEasy:
> https://issues.jboss.org/browse/RESTEASY-1137
> It doesn't make much sense that RESTEasy defines its own exception and own
> constraint validation objects that already exist in BV.
>
> Willem
>
> On Wed, Apr 15, 2015 at 2:50 PM, Santiago Pericas-Geertsen <
> Santiago.PericasGeertsen_at_oracle.com> wrote:
>
>> Hi Christian,
>>
>> The intent of the BV integration in JAX-RS is to minimize the BV code
>> apps need to write "by hand". If JAX-RS implementations throw custom
>> exception types for BV errors, there's little sense in mandating a default
>> (yet overridable) VE mapper for all JAX-RS implementations. The idea is for
>> these BV exceptions to propagate to JAX-RS applications.
>>
>> -- Santiago
>>
>> On Apr 15, 2015, at 1:21 AM, Christian Kaltepoth <christian_at_kaltepoth.de>
>> wrote:
>>
>> Hey all,
>>
>> I've a question for you.
>>
>> Imagine a resource class which uses Bean Validation annotations for
>> defining constraints. See this example:
>>
>>
>> https://github.com/chkal/jaxrs-bv/blob/master/src/main/java/de/chkal/jaxrs/MyResource.java#L12
>>
>> 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:
>>
>>
>> https://github.com/chkal/jaxrs-bv/blob/master/src/main/java/de/chkal/jaxrs/MyExceptionMapper.java#L9
>>
>> 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?
>>
>> Christian
>>
>> PS: You will find the example application which is deployable to any
>> JavaEE7 compatible container here:
>>
>> https://github.com/chkal/jaxrs-bv
>>
>>
>> --
>> Christian Kaltepoth
>> Blog: http://blog.kaltepoth.de/
>> Twitter: http://twitter.com/chkal
>> GitHub: https://github.com/chkal
>>
>>
>>
>
--
Christian Kaltepoth
Blog: http://blog.kaltepoth.de/
Twitter: http://twitter.com/chkal
GitHub: https://github.com/chkal