-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InvalidDefinitionException with inheritance and Lists #267
Comments
@vb-dci I'm not sure this is a bug with the module nor Jackson. Spring is the one deciding the type of the class to deserialize into, and it is basing this off of the runtime view of
At runtime the only thing that can be seen is that it is some @cowtowncoder ignoring the Kotlin piece. here is the main problem:
So the |
If I understand this correctly, it is much due to frameworks like Spring not using something that can actually pass type resolution context (Jackson has If this is the case, this is not solvable. |
Thanks for helping. You are right, the same problem occurs with java. |
Actually, I need to reopen this bug. I have rewrote it with Java
and it working fine. maybe someone will find a solution after all. here the full example https://github.com/vb-dci/jackson-spring-test |
maybe loading the jackson-module-kotlin is messed up in the pom? The example works if you use java collections.
|
Problem here is now that of framework: although problem can be shown in context of Spring, it can not be isolated to Jackson handling. So typically issue would be filed against Spring (since Spring controller implementation code uses Jackson in some way and defines exact calls made), and then if spring developers find a problem, they (or original reported) can file isolated example against Jackson. |
@vitaB The issue would require debugging how Spring is using the module and would be best if you could reproduce using only Kotlin + this module without Spring. I don't want to learn the internal of Spring to check out this issue which doesn't, on first glance, appear to be related to the module because things like this can work fine when called in the right way. If you can help eliminate the Spring-ness, or work through that team otherwise, it would help. |
Hello,
I found a problem with deserialization on lists and inheritance. The problem occurs when you define an abstract method to deserialize objects.
Here's a small example, I hope it's ok for you that the example also uses spring:
Here's the class to deserialize:
The error message is:
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.http.converter.HttpMessageConversionException: Type definition error: [simple type, class com.example.basecrudspringrestendpoint.presentation.dto.core.BaseDto]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinition Exception: Cannot construct instance of
com.example.basecrudspringrestendpoint.presentation.dto.core.BaseDto(no Creators, like default construct, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information at [Source: (PushbackInputStream); line: 2, column: 3] (through reference chain: java.util.ArrayList[0])] with root cause
you can find the code for this also here https://github.com/vb-dci/jackson-spring-bug
The text was updated successfully, but these errors were encountered: