Open bfkelsey opened 5 years ago
This is because com.mongodb.client.model.geojson.Point has no Jackson serializer nor deserializer. The stacktrace is clear:
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of com.mongodb.client.model.geojson.Point
(no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
You have two options:
@zigzago I included both kmongo-native
and kmongo-native-mapping
deps, however I still ran into the same issue using KMongo.createClient()
. I'm wondering if I missed something obvious here?
@channguyen please provide a test case. You can see a simple test case here: https://github.com/Litote/kmongo/commit/a55b2b3dd2e9495fccad7c24a3d07380caa43b19
Hello @zigzago, I tried to execute your sample test case and it doesn't pass. I have the following Kmong deps in my project:
implementation("org.litote.kmongo:kmongo:4.1.3")
implementation("org.litote.kmongo:kmongo-id:4.1.3")
implementation("org.litote.kmongo:kmongo-native:4.1.3")
The error I get is:
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `com.mongodb.client.model.geojson.Point` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
at [Source: de.undercouch.bson4jackson.io.LittleEndianInputStream@188cbcde; pos: 31] (through reference chain: com.octawizard.repository.reservation.Issue111MongoPoint$MyData["location"])
Is there any workaround for this?
@octawizard Remove the kmongo dependency (jackson mapping) - just keep the kmongo-native dependency
thank you @zigzago !
I am getting
com.fasterxml.jackson.databind.JsonMappingException: Cannot deserialize Class MainKt$main$PointTest (of type local/anonymous) as a Bean
when using a Mongo Point class with the Jackson client. Here is some code to reproduce the error