FasterXML / jackson-jaxrs-providers

Multi-module project that contains Jackson-based "old" JAX-RS (ones under `javax.ws.rs`) providers for JSON, XML, YAML, Smile, CBOR formats
Apache License 2.0
109 stars 77 forks source link

Reading com.fasterxml.jackson.core based Json from resteasy-jackson-provider 3.9.0 #3566 #172

Closed mehulparmariitr closed 1 year ago

mehulparmariitr commented 1 year ago

we are using Resteasy 3.9.0.Final in our vanilla java project. I have an api method which reads a POJO(Request) written in Jackson com.fasterxml.jackson.core:jackson-annotations:2.10.0.

    @Override
    @POST
    @GZIP
    @Path("/api")
    public Response call( @HeaderParam("host") @ApiParam(value = "host", required = true) String hostName,
            @ApiParam(value = "", required = true) Request request) {

But while reading it i get error -

“detailedErrorMessage”: “{\“messageDetails\“:\“Unrecognized field \\\“id\\\” (Class com.abc.api.platform.xyz.pqr), not marked as ignorable\\n at [Sou
at org.codehaus.jackson.map.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:53)
    at org.codehaus.jackson.map.deser.StdDeserializationContext.unknownFieldException(StdDeserializationContext.java:267)
    at org.codehaus.jackson.map.deser.std.StdDeserializer.reportUnknownProperty(StdDeserializer.java:673)
    at org.codehaus.jackson.map.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:659)

But when I explicit read request in string and convert it into a Request class using ObjectMapper of Fasterxml then it works fine. How to force the api method to read POJO with FasterXML ObjectMapper instead of CodeHaus?

I have this in my dependency tree also

[INFO] +- org.jboss.resteasy:resteasy-jackson-provider:jar:3.9.0.Final:compile
[INFO] |  +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:compile
[INFO] |  +- org.codehaus.jackson:jackson-jaxrs:jar:1.9.13:compile
[INFO] |  \- org.codehaus.jackson:jackson-xc:jar:1.9.13:compile
pjfanning commented 1 year ago

That resteasy-jackson-provider jar is using an unsupported old version of Jackson. One from 10 years ago.

You should not use that resteasy-jackson-provider lib and find a better maintained lib.

org.codehaus.jackson:jackson-mapper-asl and com.fasterxml.jackson.core:jackson-annotations are not related - please note the namespace differences.

mehulparmariitr commented 1 year ago

@pjfanning Which jar can be used here to read fasterxml jackson 2 JSON files? I cant change the resteasy version, it has to be 3.9.0.

pjfanning commented 1 year ago

@mehulparmariitr your question has nothing to do with this project. You will have to do your own research.

With 2 seconds googling, I found https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-jackson2-provider - maybe you try this and maybe have a look around the web yourself.

mehulparmariitr commented 1 year ago

@pjfanning i was under the impression this projects helps us choose provider for resteasy. And by adding this dependency I can provide fasterxml objectmapper to resteasy. Let me try with the dependency mentioned.

<dependency>
  <groupId>com.fasterxml.jackson.jaxrs</groupId>
  <artifactId>jackson-jaxrs-json-provider</artifactId>
  <version>2.14.1</version>
</dependency>
cowtowncoder commented 1 year ago

@mehulparmariitr This project does provide JAX-RS provider implementations usable by JAX-RS implementations. But since actual usage is from side of those frameworks, and you usually get better help from their support forums.

I hope use of provider you indicated works: good luck!