Hi,

When posting content to a JAX-RS end point, if the JSON serialization
fails, I want the to return a bad request but the framework throws a
500 internal server error.

I briefly evaluated ExceptionMappers but I couldn't get the
functionality I wanted.

Contrived examples:

@POST
@Consumes(MediaType.APPLICATION_JSON)
@Path("/car")
public Response postCars(Collection<Car> cars) {
  ....
}

public class Car {
   private final String name:
   public Cat(String name) {
       this.name = name;
   }
}

Lets say I this is the body of my post:

[{ "name" : "Ford"}, { "color" : "Hot Pink" }]

It should fail to serialize but is there a way for me to trap the
error? Or map it differently?

I can use an InputStream and serialize myself but I'd rather let the
framework do the work for me.

I'm using the jackson provider -
org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider

Warmest regards,

Trev

Reply via email to