users@jersey.java.net

[Jersey] Overriding default Bad Request response status

From: <gajo007_at_gmail.com>
Date: Mon, 17 Jun 2013 10:55:50 +0000 (UTC)

Hi,

I'm using jersey 1.9.1 and I need to override the default Bad Request
response status.
I have seen in docs that I can use ExceptionMapper<ParamException> ,
but my input parameter is a class, and neither of MatrixParam,
PathParam, QueryParam, FormParam params.

@POST
@Path("/conf")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response setConfirmation (structs.ConfirmationReq
inConfirmationReq)
{
...
}

If someone calls this method with wrong ConfReq strcutrure he will get
something like:

Can not deserialize instance of java.lang.String out of START_ARRAY
token
 at [Source: org.apache.catalina.connector.CoyoteInputStream_at_7a8a80b;
line: 4, column: 1] (through reference chain:
structs.ConfirmationReq["confirmations"]->structs.Confirmation["status"
]->structs.Status["code"])

I have a request to override this body response and show some default
error message.
Can you give me a hint?

Thank you for your help,
gajo