JAXB: How to make EntityHolder work with JSON request



Create api call looks like this:



@POST
@Path("/create")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response createEntity(EntityHolder<Entity> entity){}


If send a xml request it works fine but in case of Json payload it throws



ERROR com.macys.stars.services.core.web.rest.UnrecognizedPropertyExceptionMapper - caught an UnrecognizedPropertyException in the REST layer
21:35:36,836 INFO [stdout] (http-/0.0.0.0:8080-1) com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "someProperty" (class com.sun.jersey.core.provider.EntityHolder), not marked as ignorable (0 known properties:


Looks like jackson is confusing EntityHolder with actual Entity class.


No comments:

Post a Comment