Fixing the Support of the Replica Set by the Grails Mongo Plugin

If you’re going to use MongoDB for a production Grails application, you might run into the issue that replica sets aren’t supported in the current 1.0.0.M1 version of the MongoDB plugin.

It’s quite surprising, given that the MongoDB Java driver supports replica set configuration quite well.

The problem is that GORM — the plugin — is built on top of0.5.1 gmongo library version 0.5.1, which doesn’t support replica sets. Only the current development version 0.7 of the gmongo library supports this feature.

So, the basic method of hacking Grails to support this feature is to rebuild the GORM mongo plugin with gmongo 0.7 and use the right GMongo constructor in grails-datastore-gorm-mongo by changing one line of its source code. Then you will have to hack around a bit to rebuild everything successfully because snapshots of used modules are very unstable, and you will have to do minor hacks everywhere.

At the end, you will have something that is attached to this post – e.g., binary replacements for jars for the Grails .ivy2 repository. Just unpack the attached file with overwrite into the root of your home folder and enjoy replica set support in the hacked Mongo GORM plugin 1.0.0.M1.