Thursday, August 20, 2009

Grails on Cloud Foundry: Step by Step

After being acquired themselves last week, SpringSource has now announced acquiring Cloud Foundry. Currently Cloud Foundry only supports Amazon AWS/EC2 but in the future also VMware vSphere will be supported (surprising isn't it?).

This evening I experimented with Cloud Foundry and have uploaded a simple Grails application to the SpringSource Cloud Foundry Enterprise Java Cloud. I like to share my experiences with this step by step guide.

  1. Sign up for Cloud Foundry at

  2. Sign up for Amazon AWS at

  3. Create an EC2 keypair using the AWS Management Console or ElasticFox FireFox plugin. For detailed info and screenshots check Chris Richardson's blog post about this subject.

  4. Enable SSH using the AWS Management Console or ElasticFox. See Security Groups section. Again, for more info check Chris Richardson's blog post about this subject.

  5. Also enable HTTP access on port 80. If you forget this you won't be able to access your application in the cloud. I searched more than a hour for this...

  6. Change DataSource.groovy:

    environments {
    development {
    dataSource {
    dbCreate = "create-drop" // one of 'create', 'create-drop','update'
    driverClassName = "com.mysql.jdbc.Driver"
    username = "book"
    password = "book"
    url = "jdbc:mysql://${System.getProperty("dbHostName", "localhost")}/book"

    Change the username, password and database name (in url property). You will need to enter these credentials in Cloud Foundry later.
    The "dbHostName" property is specific for Cloud Foundry as explained in Cloud Foundry Getting Started.

  7. Download the MySQL Connector/J jar and add it to your project's lib folder.

  8. After changing DataSource.groovy and adding the MySQL jar build a Grails war file using grails war.

  9. Login to Cloud Foundry at Don't use IE7! Be warned.

  10. Navigate to the applications tab and upload you war file. Important things to enter are the application name, the war file to upload, context name and the database section. Leave the rest as is.

  11. After your application is uploaded it's time to deploy it. Click the application's deploy button. In the next screen just enter a deployment name and leave the rest as is. Now hit the Launch button.

  12. This will take some time, but it's worth it ;-)

  13. After lauching your application click to view the deployment details. There is a Go To Home Page link to access your application!

    Note: If you are using Google Chrome you won't see the link... That's why my first deployment 'failed' (and a hour gone) as I didn't know how to access it. As IE7 doesn't work either I guess Cloud Foundry only supports FireFox currently (I don't mind about IE, but I would be happy with Chrome).

To be honest Cloud Foundry has some rough edges in terms of documentation and tooling support but at the end I'm very happy how simple it is to deploy a Grails application. No Apache, Tomcat or MySQL setup anymore. This is the future!

Now only pricing should be more affordable. $79,20 p/month (Amazon AWS) for a toy project/application is a little bit high.

Monday, August 10, 2009

Will Rod Johnson be the next Marc Fleury?

Yesterday VMware announced it is going to acquire SpringSource for around $420 million. They expect the deal to be closed in Q3 2009. This means not only acquiring the Spring framework, but also Groovy, Grails, SpringSource tc Server (Apache Tomcat), SpringSource dm Server, Roo, etc.

As a Java developer I'm making use of a lot of SpringSource products (Spring framework, Groovy, Grails) so I'm wondering what this will mean for us. The VMware blog stated that the Spring framework (and I assume the same counts for the other products) will stay open and that Rod Johnson will continue to lead SpringSource. Let's hope Rod will not go on a "Paternity Leave" like Marc Fleury did ;-)

I think a lot of attention will go to cloud computing. Both the VMware blog and SpringSource Team Blog speak a lot about it. To quote Rod Johnson: "Working together with VMware we plan on creating a single, integrated, build-run-manage solution for the data center, private clouds, and public clouds". Also Graeme Rocher (Head of Grails Development - SpringSource) tweeted that we can expect exciting developments around Grails + Cloud coming in the not too distant future.

The VMware SpringSource acquisition also means my latest prophecy that Oracle will buy SpringSource someday needs a slight change... I think Oracle will buy VMware someday.

Grails w/ Dojo enabled forms

Didn't touched my Blogger account for almost a month now and I think regular tweeting is not good for the number of entries on your blog... But twitter is limited to 140 characters and I needed a little bit more this time.

While playing with Spring Roo the other day I noticed Roo is using Dojo - and to be more specific Dijit Forms - to enhance plain htlm input fields with javascript. For example Number fields are decorated with a Dojo dijit.form.NumberTextBox; what this means is that the user can only enter digits and no text. The lack of this feature with plain html inputs is a problem that has always bothered me when developing 'business' web applications.

So I dived into the magic of Dojo and it's Dijit form controls last week, and it does not only validate values using javascript, but it also contains nice widgets.

During the weekend I decided to create a small Grails application to leverage all Dijit form controls using a tag library. The following Dijit enabled form controls are available in this tag library:

  • actionSubmit

  • checkBox

  • currencyTextBox

  • comboBox (note: do not confuse this one with a filteringSelect)

  • dateTextBox

  • editor

  • filteringSelect

  • form

  • multiSelect

  • numberTextBox

  • numberSpinner

  • passwordTextBox

  • radioButton

  • radioGroup

  • simpleTextarea

  • submitButton

  • textarea

  • textBox

  • validationTextBox

Example screenshots:

The complete application code and a little bit more information can be found at: I will use this repository to share more Grails snippets in the future.