cf play/scala autoconfiguration for mysql

50 views
Skip to first unread message

Rags

unread,
Dec 9, 2014, 3:25:46 PM12/9/14
to vcap...@cloudfoundry.org
Hello:

Noob at Scala/Play and CF.

I am using play 2.2.6. 

I started with the samples computer-database example. Idea is to automatically configure the mysql service. I adapted the evolution scripts from

to computer-database sample.

Manual configuration as below (I use the values from $cf env computers) works fine.

db.default.driver=com.mysql.jdbc.Driver

db.default.url="jdbc:mysql://url"

db.default.user=user

db.default.password=password

However auto configuration fails as below.

ERR Dec 09, 2014 6:43:02 PM org.cloudfoundry.reconfiguration.play.Configurer configure

2014-12-09T13:43:02.82-0500 [App/0]   ERR INFO: No databases found. Skipping auto-reconfiguration.

What am missing for the auto configuration? Ideally, I would like to get this working.

I am open to listening to alternatives such as

https://github.com/cloudfoundry-samples/zentasks-scala-cloudfoundry/blob/master/conf/application.conf#L20-L22

as suggested by Scott F., but I am not sure how to set the manifest to incorporate these values and use them in application.conf.

Just including the following line.

db.default.driver=com.mysql.jdbc.Driver

fails with an URL required.

Help (with some detailed steps) will be appreciated.

Thanks!

Rags

Johannes Tuchscherer

unread,
Dec 10, 2014, 5:45:58 AM12/10/14
to vcap...@cloudfoundry.org
Hi Rags,

The following page is a little bit out of date (it references the old CloudFoundry command line tool - vmc - instead of the new one - cf). But if you look at the section at the bottom, you will see how Auto-Reconfiguration works with Scala and CloudFoundry:

I hope that helps,
Johannes

Rags

unread,
Dec 10, 2014, 11:03:34 AM12/10/14
to vcap...@cloudfoundry.org
Johannes:

I did look at this before and I finally got it working with some trial and error. From the docs.

> Cloud Foundry will automatically override the connection properties in the configuration to point to the PostgreSQL or MySQL service bound to the application.
> If you use the properties referenced above, you will automatically be opted-out.

When I do not explicitly reference the properties, auto configuration does not seem to work.

2014-12-10T10:08:16.83-0500 [App/0]   ERR INFO: No databases found. Skipping auto-reconfiguration.

I expected it to automatically configure p-mysql (the bound service) which it did not.

I minimally need the following in the application.conf file to make this work.

db.default.driver=com.mysql.jdbc.Driver

db.default.url=${?cloud.services.p-mysql.connection.jdbcurl}

I could not pull the db.default.driver information from the environment variables (unless I am missing something). Since the jdbcUrl has the URL, username and password, I don't need anything else.

I think this seems acceptable, but auto configuration working out of the box would be ideal.

Thanks!

Rags

Reply all
Reply to author
Forward
0 new messages