Question

recently, I am working in a grails project and intend to use mongodb as our nosql database, besides mysql.

I added mongodb plugin, do a test with a domain and it work well (show/edit/save...):

compile ':mongodb:3.0.1'

and try another method using gmongo plugin, which is useful in case I want to use mongodb low level API (or using mapReduce for example)

runtime "org.mongodb:mongo-java-driver:2.11.3"
compile "org.mongodb:mongo-java-driver:2.11.3"
runtime "com.gmongo:gmongo:1.3"

try to test with a simple query find(), it works well too

Now I want to combine 2 method and here is the error:

| Error 2014-05-13 17:52:07,197 [localhost-startStop-1] ERROR plugins.DefaultGrailsPluginManager  - Error configuring dynamic methods for plugin [mongodb:3.0.1]: com/mongodb/AggregationOptions
Message: com/mongodb/AggregationOptions
    Line | Method
->> 2531 | privateGetDeclaredMethods in java.lang.Class
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1855 | getDeclaredMethods        in     ''
|     46 | getLocked . . . . . . . . in org.codehaus.groovy.util.LazyReference
|     33 | get                       in     ''
|     98 | createGormStaticApi . . . in org.grails.datastore.gorm.mongo.plugin.support.MongoMethodsConfigurer
|     65 | configure                 in org.grails.datastore.gorm.plugin.support.DynamicMethodsConfigurer
|     49 | configure . . . . . . . . in org.grails.datastore.gorm.mongo.plugin.support.MongoMethodsConfigurer
|     76 | doCall                    in MongodbGrailsPlugin$_closure2
|    262 | run . . . . . . . . . . . in java.util.concurrent.FutureTask
|   1145 | runWorker                 in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run                       in java.lang.Thread
Caused by ClassNotFoundException: com.mongodb.AggregationOptions
->>  366 | run                       in java.net.URLClassLoader$1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    355 | run                       in     ''
|    354 | findClass . . . . . . . . in java.net.URLClassLoader
|    425 | loadClass                 in java.lang.ClassLoader
|   2531 | privateGetDeclaredMethods in java.lang.Class
|   1855 | getDeclaredMethods        in     ''
|     46 | getLocked . . . . . . . . in org.codehaus.groovy.util.LazyReference
|     33 | get                       in     ''
|     98 | createGormStaticApi . . . in org.grails.datastore.gorm.mongo.plugin.support.MongoMethodsConfigurer
|     65 | configure                 in org.grails.datastore.gorm.plugin.support.DynamicMethodsConfigurer
|     49 | configure . . . . . . . . in org.grails.datastore.gorm.mongo.plugin.support.MongoMethodsConfigurer
|     76 | doCall                    in MongodbGrailsPlugin$_closure2
|    262 | run . . . . . . . . . . . in java.util.concurrent.FutureTask
|   1145 | runWorker                 in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run                       in java.lang.Thread

I don't know how to fix it actually!

Was it helpful?

Solution

Mongodb Plugin is a wrapper over GMongo with the power of GORM features. You can definitely use GMongo or lower level API directly from the plugin instead of adding those dependencies explicitly.

Have a look at the build.gradle where they are included. Most likely the error is due to conflicting dependencies when both of them are used simultaneously.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top