cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <>
Subject Re: customize error messages for bad input requests
Date Fri, 11 Apr 2014 11:18:11 GMT
On 10/04/14 22:23, Raul Acevedo wrote:
> On 2014-04-10 12:49, Jose MarĂ­a Zaragoza wrote:
>> According exception
>> should be
>> javax.validation.ConstraintViolationException or
>> javax.validation.ValidationException
>> How are you setting up Bean Validation feature  ?
> I'm still trying to set it up, but that's not the problem.  I'm still
> trying to customize the response when CXF converts arguments to the
> native Java types; this isn't done by bean validation.  Per my original
> example:
>      @GET @PATH("/{foo}/{bar}")
>      public Response foo(@PathParam("foo") Integer foo,
> @PathParam("bar") Integer bar) {
>          ... do stuff ...
>      }
> No bean validation is used here, this is just basic input parameter
> binding.  CXF throws a fairly generic ClientErrorException, which
> doesn't tell me that the problem is that input binding failed.
You are right, Bean validation can not be effective here given that it 
is applied after the parameters have been initialized, I missed it...

Note ClientErrorException will have a cause initialized to 
NumberFormatException in this case, so this is one way to manage it.

Otherwise I can only think of registering a PreMatch 
ContainerRequestFilter which will validate the request URI.

HTH, Sergey

> Ideally I'd like a solution that works for both bean validation (once I
> get that working) and input binding, but for now I don't see a way to do
> even the basic input binding error response handler.
> Thanks,
> Raul

Sergey Beryozkin

Talend Community Coders


View raw message