I'm using Jersey 2.25.1 and JackSon 2.x as Json provider (https://jersey.github.io/documentation/latest/media.html#json.jackson).
In a service I'd like to get the request directly as JsonNode but I get this exception: java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.ObjectReader.forType(Lcom/fasterxml/jackson/databind/JavaType;)Lcom/fasterxml/jackson/databind/ObjectReader
I could get it as a string and turn it to JsonNode but I was expecting JsonNode could directly be resolved.
Here is the service:
@PUT
@Path("/test")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Override
public Response methode1(JsonNode jsonRequest)
throws JsonProcessingException, IOException {
return super.methode1(jsonRequest);
}
I guess my problem comes from the ContextResolver I got from Jersey sample (https://github.com/jersey/jersey/blob/2.26-b07/examples/json-jackson/src/main/java/org/glassfish/jersey/examples/jackson/MyObjectMapperProvider.java).
Note this mapper works for other services which returns JsonNode type as a response. Where and how should I implement the "reader" part?
EDIT: as shazin noticed it is a versions compatibility problem. One of my dependencies needs Jackson 2.3.3 whereas jersey-media-json-jackson 2.25.1 needs Jackson 2.8.4. The 2.3.3 version was chosen by maven and just adding explicit 2.8.4 dependency did the job.