Grails

Starting Grails application with custom path

I am speaking about development mode. When you start your application with “grails run-app” by default it will be located at http://localhost:8080/[your application name]. But what if we’d like to start our aplication for example in a server root? Or in any other custom path?

Lets try to do this! The steps are following:

  • application.properties - add the value app.path=/MyApp, where /MyApp is the path with which you’re going to access your web-application
  • Then you should need to modify some scripts in your Grails installation. The first one is $GRAILS_HOME/scripts/Init.groovy. Add: grailsAppPath = “/” (near of “grailsAppName = null”, in 1.0.2 it is line 75), and grailsAppPath = props.’app.path’ (line 101, near of grailsAppName = props.’app.name’)
  • The rest is to modify $GRAILS_HOME/scripts/RunApp.groovy: event(”StatusFinal”, [”Server running. Browse to http://localhost:$serverPort${grailsAppPath}”]) (line 70) and webContext = new WebAppContext(”${basedir}/web-app”, “${grailsAppPath}”) (line 117)

Now you can start your application with “grails run-app”! Notice that if you want use https then you should also make similar changes in $GRAILS_HOME/scripts/RunAppHttps.groovy file. I’ve mentioned line numbers but it is for 1.0.2 version only.

Exception #07

You can read in russian my report on Exception #07 conference. In brief - this was a great experience for me. And in the nearest future I’ll share all materials.