Quantcast

Autoconfiguration of MongoDB on Cloud Foundry v2

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Autoconfiguration of MongoDB on Cloud Foundry v2

Craig Raw
Hi,

I have been chatting to Ben Hale, one of the Cloud Foundry Java buildpack developers, and it seems that autoconfiguration no longer works when deploying a Grails app with the mongodb plugin to Cloud Foundry.

For autoconfiguration to work, CF looks for a bean in the application context of type org.springframework.data.mongodb.MongoDbFactory, and reconfigures that with the configuration details of the CF provided mongo instance. However, the Grails mongodb plugin doesn't use/expose this bean (although it does use the spring-data-mongodb library from which it comes), so autoconfiguration does not occur.

The workaround is using the spring-cloud jars and adding some code to DataSource.groovy to explicitly fetch the mongo configuration details from the cloud and set them appropriately.  This works, although it's arguably not ideal for all circumstances.

I'd like to ask whether it's possible to expose org.springframework.data.mongodb.MongoDbFactory in some way to make autoconfiguration possible, or failing that some direction on the appropriate starting point to help the CF guys get Grails+MongoDB autoconfiguration working again.

Thanks,
Craig


**********************************************************************
Please read our email disclaimer. It sets out our position on the content, integrity and security of this confidential email and explains what to do if you have received it in error.
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Autoconfiguration of MongoDB on Cloud Foundry v2

Graeme Rocher-2
I guess what needs to happen is that MongoSpringConfigurer needs to
registry a MongoDbFactory instance here:
https://github.com/grails/grails-data-mapping/blob/master/grails-datastore-gorm-mongodb/src/main/groovy/org/grails/datastore/gorm/mongo/plugin/support/MongoSpringConfigurer.groovy#L81

Instead of just creating a Mongo instance

Cheers

On Wed, May 28, 2014 at 12:20 PM, Craig Raw <[hidden email]> wrote:

> Hi,
>
> I have been chatting to Ben Hale, one of the Cloud Foundry Java buildpack
> developers, and it seems that autoconfiguration no longer works when
> deploying a Grails app with the mongodb plugin to Cloud Foundry.
>
> For autoconfiguration to work, CF looks for a bean in the application
> context of type org.springframework.data.mongodb.MongoDbFactory, and
> reconfigures that with the configuration details of the CF provided mongo
> instance. However, the Grails mongodb plugin doesn't use/expose this bean
> (although it does use the spring-data-mongodb library from which it comes),
> so autoconfiguration does not occur.
>
> The workaround is using the spring-cloud jars and adding some code to
> DataSource.groovy to explicitly fetch the mongo configuration details from
> the cloud and set them appropriately.  This works, although it's arguably
> not ideal for all circumstances.
>
> I'd like to ask whether it's possible to expose
> org.springframework.data.mongodb.MongoDbFactory in some way to make
> autoconfiguration possible, or failing that some direction on the
> appropriate starting point to help the CF guys get Grails+MongoDB
> autoconfiguration working again.
>
> Thanks,
> Craig
>
> (Conversation on CF forum here:
> https://groups.google.com/a/cloudfoundry.org/forum/#!topic/vcap-dev/ixuMoCT2tlM)
>
> **********************************************************************
> Please read our email disclaimer. It sets out our position on the content,
> integrity and security of this confidential email and explains what to do if
> you have received it in error.
> **********************************************************************



--
Graeme Rocher
Grails Project Lead
SpringSource

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Autoconfiguration of MongoDB on Cloud Foundry v2

Craig Raw
Thanks Graeme.

I have been working to update my mongo-file plugin with Cloud Foundry - the route I've ended up going is removing the dependency on the mongodb plugin and bringing in the spring-data-mongodb library as a dependency instead. I then put the MongoDbFactory from that lib into the Spring application context and everything works fine, and its a lighter solution too.

Anyway, just flagging that the mongodb plugin will need similar treatment if it's to work on Cloud Foundry v2.

Craig


On 28 May 2014 13:33, Graeme Rocher <[hidden email]> wrote:
I guess what needs to happen is that MongoSpringConfigurer needs to
registry a MongoDbFactory instance here:
https://github.com/grails/grails-data-mapping/blob/master/grails-datastore-gorm-mongodb/src/main/groovy/org/grails/datastore/gorm/mongo/plugin/support/MongoSpringConfigurer.groovy#L81

Instead of just creating a Mongo instance

Cheers

On Wed, May 28, 2014 at 12:20 PM, Craig Raw <[hidden email]> wrote:
> Hi,
>
> I have been chatting to Ben Hale, one of the Cloud Foundry Java buildpack
> developers, and it seems that autoconfiguration no longer works when
> deploying a Grails app with the mongodb plugin to Cloud Foundry.
>
> For autoconfiguration to work, CF looks for a bean in the application
> context of type org.springframework.data.mongodb.MongoDbFactory, and
> reconfigures that with the configuration details of the CF provided mongo
> instance. However, the Grails mongodb plugin doesn't use/expose this bean
> (although it does use the spring-data-mongodb library from which it comes),
> so autoconfiguration does not occur.
>
> The workaround is using the spring-cloud jars and adding some code to
> DataSource.groovy to explicitly fetch the mongo configuration details from
> the cloud and set them appropriately.  This works, although it's arguably
> not ideal for all circumstances.
>
> I'd like to ask whether it's possible to expose
> org.springframework.data.mongodb.MongoDbFactory in some way to make
> autoconfiguration possible, or failing that some direction on the
> appropriate starting point to help the CF guys get Grails+MongoDB
> autoconfiguration working again.
>
> Thanks,
> Craig
>
> (Conversation on CF forum here:
> https://groups.google.com/a/cloudfoundry.org/forum/#!topic/vcap-dev/ixuMoCT2tlM)
>
> **********************************************************************
> Please read our email disclaimer. It sets out our position on the content,
> integrity and security of this confidential email and explains what to do if
> you have received it in error.
> **********************************************************************



--
Graeme Rocher
Grails Project Lead
SpringSource

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
Craig Raw | Quirk
CTO 
--
t. 021 462 7353
w. www.quirk.biz
me. bit.ly/craigraw


**********************************************************************
Please read our email disclaimer. It sets out our position on the content, integrity and security of this confidential email and explains what to do if you have received it in error.
**********************************************************************
Loading...