This week we were looking for a service to deploy a small grails application and find Pivotal Web Services, a platform that is built on top of cloud foundry, that caused our attention.

Please don’t expect to have a long tutorial here, we will focus on a single error that may stop some of us from deploying grails to CF, you will find we are doing a lot of assumptions on things you should have installed on your machine, cf, grails and a lot more.

In order to test a simple mysql grails application we did create a new grails project using grails 2.4.0, something like:

grails create-app OurApp

After that we followed Pivotal’s instruction on configuring grails, we did add:

 repositories {
    grailsHome()
    mavenCentral()
    grailsCentral()
    mavenRepo "http://repo.spring.io/milestone"
 }
 dependencies {
    compile "org.springframework.cloud:cloudfoundry-connector:0.9.5"
    compile "org.springframework.cloud:spring-service-connector:0.9.5"
 }

Into our Buildconfig.groovy, and do the database bit as pivotal’s link mentioned. which caused us an error when trying to run the app, something like:

 java.lang.NoClassDefFoundError: org/springframework/context/EnvironmentAware

[ 10 Ruby guys running now :D ]

After about an hour researching we find that we needed to add:

 compile "org.springframework:spring-context:$springVersion"

Under dependencies inside our lovely Buildconfig.groovy.

At the end we did run

 grails prod war && cf push ourApp -p target/ourApp.war

And wait for the deployment.

Happy Deployment!