Discussion:
Autoconfiguration of MongoDB on Cloud Foundry v2
Craig Raw
2014-05-28 10:20:47 UTC
Permalink
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*<http://www.quirk.biz/downloads/legal/Quirk_Email_Disclaimer.pdf>.
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
2014-05-28 11:33:50 UTC
Permalink
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
Post by 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
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
2014-05-29 13:35:31 UTC
Permalink
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
Post by Graeme Rocher
I guess what needs to happen is that MongoSpringConfigurer needs to
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
Post by 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),
Post by Craig Raw
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
Post by Craig Raw
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
https://groups.google.com/a/cloudfoundry.org/forum/#!topic/vcap-dev/ixuMoCT2tlM
)
Post by Craig Raw
**********************************************************************
Please read our email disclaimer. It sets out our position on the
content,
Post by Craig Raw
integrity and security of this confidential email and explains what to
do if
Post by Craig Raw
you have received it in error.
**********************************************************************
--
Graeme Rocher
Grails Project Lead
SpringSource
---------------------------------------------------------------------
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*<http://www.quirk.biz/downloads/legal/Quirk_Email_Disclaimer.pdf>.
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...