Reputation: 2273
I'm encountering a JsonMappingException when serializing a response in my Micronaut application using Jackson. The error trace is as follows:
org.jetbrains.kotlin.name.ClassId (through reference chain: com.ecwid.apiclient.v3.dto.order.result.OrdersSearchResult["items"]->java.util.ArrayList[0]->com.ecwid.apiclient.v3.dto.order.result.FetchedOrder["modifyKind"]->com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO$ModifyKind$ReadWrite["updatedDTOClass"])
com.fasterxml.jackson.databind.JsonMappingException: org.jetbrains.kotlin.name.ClassId (through reference chain: com.ecwid.apiclient.v3.dto.order.result.OrdersSearchResult["items"]->java.util.ArrayList[0]->com.ecwid.apiclient.v3.dto.order.result.FetchedOrder["modifyKind"]->com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO$ModifyKind$ReadWrite["updatedDTOClass"])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:402)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:361)
Caused by: java.lang.ClassNotFoundException: org.jetbrains.kotlin.name.ClassId
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
at kotlin.reflect.jvm.internal.KDeclarationContainerImpl.parseType(KDeclarationContainerImpl.kt:291)
at kotlin.reflect.jvm.internal.KDeclarationContainerImpl.loadReturnType(KDeclarationContainerImpl.kt:306)
I am using the following dependencies
implementation "com.fasterxml.jackson.module:jackson-module-kotlin"
implementation 'io.micronaut:micronaut-jackson-databind'
implementation "com.ecwid.apiclient:api-client:0.351.0"
micronautVersion=4.7.4
After inspecting the dependency tree with ./gradlew dependencies --configuration compileClasspath | grep kotlin, I see the following versions:
$ ./gradlew dependencies --configuration compileClasspath | grep kotlin
+--- com.fasterxml.jackson.module:jackson-module-kotlin -> 2.17.2
| | | +--- com.fasterxml.jackson.module:jackson-module-kotlin:2.17.2 (c)
| +--- org.jetbrains.kotlin:kotlin-reflect:1.7.22 -> 1.9.25
| | \--- org.jetbrains.kotlin:kotlin-stdlib:1.9.25
| +--- org.jetbrains.kotlin:kotlin-bom:1.9.25
| | +--- org.jetbrains.kotlin:kotlin-reflect:1.9.25 (c)
| | \--- org.jetbrains.kotlin:kotlin-stdlib:1.9.25 (c)
| +--- org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.8.1
| +--- com.fasterxml.jackson.module:jackson-module-kotlin:2.17.2 (c)
| +--- org.jetbrains.kotlin:kotlin-reflect:1.9.25 (c)
| +--- org.jetbrains.kotlin:kotlin-stdlib:1.9.25 (c)
+--- io.micronaut.kotlin:micronaut-kotlin-bom:4.5.0
| +--- com.fasterxml.jackson.module:jackson-module-kotlin:2.16.1 -> 2.17.2 (c)
How can I ensure that Jackson handles Kotlin objects properly in this setup?
Upvotes: 0
Views: 42