users@jersey.java.net

[Jersey] JAXRS 2.0 Bean Validation error, how to return XML and not HTML

From: Richard Kolb <rjdkolb_at_gmail.com>
Date: Mon, 29 Jul 2013 14:17:12 +0200

Hello

I have a simple Restful webservice :
    @GET
    @Path("/order")
    @Produces(MediaType.APPLICATION_XML)
    public MyResult placeOrder(@Min(message="Min order is 10 cents",
value=10) @QueryParam("amountCents") Integer amountCents) {}

When I pass in less than 10 to amountCents, jersey gives back a error in
HTML, but I would like it in XML.

I also have an application that looks like :
@ApplicationPath("rest/*")
public class SnailApplication extends Application {
    @Override
    public Map<String, Object> getProperties() {
        Map<String,Object> props = new HashMap<>();
        props.put(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);
        return props;
    }
}

I have had a look here :
https://jersey.java.net/documentation/latest/user-guide.html#bv.ValidationError
But I think I am missing something.

Help please.

thanks
Richard.