0

I'm currently writing a Grails app using Grails 2.2.2 and MySQL, and have been deploying it to Cloudfoundry.

Until recently I've just used a single MySQL datasource for my domain, which Cloudfoundry detects and automagically creates and binds a MySQL service instance to.

I now have a requirement to store potentially large files somewhere, so I figured I'd take a look at MongoDB's GridFS. Cloudfoundry supports MongoDB, so I'd assumed Cloudfoundry would do some more magic when I deployed my app and would provide me with a MongoDB datasource as well.

Unfortunately I'm not prompted to create/bind a MongoDB service when I deploy my app, and I think this may be down to the way I'm connecting to Mongo.

I'm not using the MongoDB plugin, as this conflicts with another plugin I'm using, and in any case I don't need to persist any of my domain to Mongo - just some large files - so I'm using the Mongo java driver directly (similar to this - http://jameswilliams.be/blog/entry/171).

I'm unsure how Cloudfoundry detects that your application requires a particular datasource, but I'd assumed it would figure this out somehow from DataSource.groovy.

Mine looks like this...

environments {
    development {
        dataSource {
            driverClassName = "com.mysql.jdbc.Driver"
            dbCreate = "create-drop" 
            ...
        }
        dataSourceMongo {
            host = "localhost"
            port = 27017
            dbName = "my_mongo_database_name"
            ...
        }
    }
}

Is there something I'm missing? Or do I need to manually bind the MongoDB service somehow?

rcgeorge23
  • 3,594
  • 4
  • 29
  • 54
  • To understand presence of multiple datasources in grails app the non-default `datasource` has to be named as `datSource_Mongo` (with an underscore). Have you tried that option? – dmahapatro May 01 '13 at 13:18
  • Thanks for the tip - I've changed `dataSourceMongo` to `dataSource_mongo` but Cloudfoundry still doesn't prompt to bind a Mongo instance to it. – rcgeorge23 May 01 '13 at 18:18

1 Answers1

0

Using answer instead of comments for better formatting. :)

I guess you have already followed step to create the MongoDB service in Cloudfoundry as mentioned here otherwise this has to be done. Plus, it will be lot easier if you use the Groovy wrapper of the Java Driver of MongoDB called GMongo. Refer the GitHUb Source and this Mongo blog for more details.

dmahapatro
  • 49,365
  • 7
  • 88
  • 117
  • Unfortunately I'm not able to use the MongoDB plugin - I think some of the hibernate filter stuff interferes with the multi tenant plugin which I am already using. Yes, I'd already tried creating the MongoDB service manually first, but still no luck. I'm considering other options at the moment (such as storing file on the filesystem and not deploying to Cloudfoundry!) – rcgeorge23 May 02 '13 at 08:18