Unable to insert document with a field of type BsonBinary
When trying to create a collection and seed some data as part of a changeUnit i receive the following error because my model has a field of type BsonBinary.
Caused by: org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class org.bson.BsonBinary_$$_mongock_78c_5.
This is a valid type as its used as part of the Client Side Field Level Encryption. Is the mongo-driver used by mongock out of date with the latest version used in spring boot? Are there any workaround for this?
Hello @mcveighc ,
the MongoDB driver dependency is imported by your project, if you see the scope is provided, so that shouldn't be the problem.
Have you tried that without Mongock, I believe is not related to Mongock nor MongoDB driver. Instead I think somehow the codec is missing and needs to be provided
@dieppa thanks for quick response.
Yeah strangely it works fine when i use my mongo repository with the same model. I tried a few different routes to insert the data in the changeUnit and seemed to get the same or similar issues.
- Inject mongoTemplate via method parameter
- Inject mongoTemplate via constructor parameter
- Inject dedicated repository via constructor parameter and insert
- Grab the collection from the mongoTemplate using codecs from
MongoClientSettings.getDefaultCodecs()and insert
It almost seems when running in the mongock boundary it cant find them for some reason.
Hello @mcveighc ,
I think the easiest way to approach this is you setting up a dummy project in github reproducing this issue, grant me access and I can debug it. Is that something you can do?
Hi @dieppa
I've created a private repo and added you as a collaborator. There are instructions on the readme how to run it.
Let me know if you have trouble. Thanks