CollectionCodecProvider class not found on new Grails 6 project

70 Views Asked by At

We are currently upgrading a project from Grails 5 to Grails 6, which uses mongodb. Going through the migration documentation, at a certain point of trying to run run the application it starts failing due to class org/bson/codecs/CollectionCodecProvider not being found. After investigating the dependencies, it appears that the org.mongodb:bson dependency is being downgraded from 4.11 to 4.6, and version 4.6 does not have the missing class.

I assumed that some other existing dependency was conflicting with the updated mongodb dependency and causing the older version of the bson dependency to be pulled in, however I have yet to be able to identify what was causing it.

To try to further verify that this is what is happening, I created a new project from scratch using the grails 6.1.2.

grails create-app grails6 --profile rest-api --features events,json-views,markup-views,mongodb

With the new project I started trying to get it to the point that it could run and connect to mongo, however it appears that this default project is also running into the same issue. The bson dependency is resolving to version 4.6.1 and the expected class is missing.

I'm assuming I could get around this problem by explicitly adding the bson dependency to the project as the 4.11.1 version, but I would like to understand why this conflict exists and why it is being downgraded.

  • Grails: 6.1.2
  • Java: 11.0.6
1

There are 1 best solutions below

0
Lucas c10 On

Im migrating to this version hehe. And same problem here.

In my personal experience, was very frustrating to migrate to grails 5... now the migration to grails 6 seems more easy, but this errors frustrate the migration again.

Try to create a bug inside "issues" of github project. We can obtain more responses from there: https://github.com/grails/gorm-mongodb/issues


UPDATE

after adding this explicit dependency, now it really works. There is workaround, at least, until some fix is created in the driver. Add this to the build.gradle:

// https://mvnrepository.com/artifact/org.mongodb/bson

implementation 'org.mongodb:bson:4.11.1'

Greetings