I am using the @JsonTypeInfo mechanism in order to achieve Polymorphism of data objects sent to a REST API. I've encountered the problem of my type property added twice, which is clearly explained is this jackson issue (I'm not putting my code in here because the code in the top of that issue is similar to mine). According to this issue, it's a known problem which can only be solved by using the JsonTypeInfo.As.EXISTING_PROPERTY.
Unfortunately, I didn't find any code example showing a simple use case using the JsonTypeInfo.As.EXISTING_PROPERTY - I mean, I thought these Unit tests, which are part of the jackson-databind project, can be used as an example, but the moment I'm replacing JsonTypeInfo.As.PROPERTY with JsonTypeInfo.As.EXISTING_PROPERTY, I'm getting response with status code 400 from my server, with the following response body:
"Do not know how to construct standard type serializer for inclusion type: EXISTING_PROPERTY".
I've debugged it, and all my business logic works fine - until the point where the response object is sent back to client (I'm using the standard javax.ws.rs.core.Response.ResponseBuilder to build the response with all the retrieved data objects)
I've tried using another solution described in: Unexpected duplicate key error using @JsonTypeInfo property , which suppose to solve the duplicate key issue and still use the JsonTypeInfo.As.PROPERTY - but it just didn't solve the duplication issue.
My server is tomcat 8, my code on the server-side is written in Java 8, I'm using Spring 4, Jersey 2.14 for REST, and I've configured my project to work with the latest jackson-annotations version from their git repository (2.6.0-rc3-SNAPSHOT) - since in the jackson ticket they've specified that only from this version JsonTypeInfo.As.EXISTING_PROPERTY will be working properly.