0

My application needs to use mongodb for normal data storage and also to keep pretty large files. Hence I started with plugins for mongodb (for normal data storage) and gridfs (for large files).
I am using grails 2.3.4 and trying to figure out what is the issue with the plugins that are included for using both mongodb and gridfs.

I have been searching the entire internet (including stalkoverflow) to find out any plugins that co-exists but in vain. Because no matter I use what combination of the available plugins, it all shows errors saying compatibility issues.

I am using the driver mongo-java-driver-2.11.3.jar

I ended up trying all plugins currently available. My build-config file looks like this: <<<

//        compile ":mongodb:1.3.3"
//        compile ":mongodb:1.0.0.GA"
//        compile ":gorm-mongodb:0.5.4" 
//        compile ":zk-mongodb:1.1-M1"
          compile ":mongodb-morphia:0.8.2"

          compile ":mongo-file:1.1.1"   
//        compile ":mongodb-gridfs:0.5.beta"

> I know that I am missing something here. Has anybody used grails2.3.4 and mongodb with gridfs ?

Please help me out either by pointing the correct plugins or sending code snippets of working samples.

Thank you all in advance.

Gsb
  • 3
  • 3
  • Can you include the error messages? – Emmanuel John Dec 27 '13 at 04:36
  • The error message is: Resolve error obtaining dependencies: The following artifacts could not be resolved: org.grails:grails-datastore-gorm-mongo:jar:1.0.0.RC3, org.springframework.data:spring-data-mongodb:jar:1.0.0.RC1, org.grails:grails-datastore-mongo:jar:1.0.0.RC3, org.grails:grails-datastore-gorm-plugin-support:jar:1.0.0.RELEASE, org.grails:grails-datastore-web:jar:1.0.0.RELEASE, org.springframework.data:spring-data-commons-core:jar:1.2.0.RC1: Could not find artifact org.grails:grails-datastore-gorm-mongo:jar:1.0.0.RC3 in grailsCentral (http://repo.grails.org/grails/plugins) – Gsb Dec 27 '13 at 12:12
  • Because of this error, I downloaded and copies the jar file (grails-datastore-gorm-mongo:jar:1.0.0.RC3) into the lib folder. But still this error pops up while compiling. Has anybody worked on mongodb-gridfs using grails 2.3.4? – Gsb Dec 27 '13 at 12:17

2 Answers2

1

I had a similar problem when I used ":mongodb-gridfs:0.5.beta" as well. In fact, even when I tried to remove the plugin (via my IDE) it continued to error. I deleted plugins.mongodb-gridfs=0.5.beta from application.properties, and then my application could build again.

You shouldn't need a separate plugin to use GridFS, it's actually part of the MongoDB Java driver. You will, however, need to get to the lower-level API instead of using the default Grails GORM stuff - there's some info on how to do this here.

The GridFS API works in a slightly different way to the rest of the driver, but here's an example. To create the GridFS to work with, you'll need something like new GridFS(mongo.getDB(databaseName)).

I don't have a fully working example to show you, but I hope you can piece together what you need from those different examples.

Trisha
  • 3,891
  • 1
  • 25
  • 39
0

I've been using webfs which has worked very well for us in the past. It's a lightweight grails plugin for managing files using Mongo's gridfs. See https://github.com/dlaidlaw/mongo-web-filesystem for more details.

I use the webfs plugin in our document management module for managing any type of documents, up to 250MB in size. Am using mongodb:1.2.0.

I've not tested it with Grails 2.3.4, but it works on 2.0, 2.1 and 2.2.

Arnar B
  • 111
  • 1
  • 2
  • Thank you very much for taking time to provide this help. How will I include it in my grails app? Since I am not very proficient in grails, just want to know what should I put in buildconfig file? (Like the compile statements that I have pasted in the beginning of this post?). – Gsb Dec 27 '13 at 19:18