Thursday, September 4, 2008

An Annexure - Grails deployment in Tomcat 6.0/ Ubuntu


After first upload of your grails app, when you follow the same process to upload an update, the grails app sometimes doesn't work. I have no idea why but here are the steps to solve this.

  1. Always upload the war file into /jakarta_tomcat directory.
  2. After upload copy the file into webapps directory.
  3. In since webapps/ROOT is the default directory, create a backup of the ROOT directory, anywhere outside the webapps directory.
  4. Unzip the newly loaded war file.
  5. Place the contents into the root directory.
  6. Move the .war file outside webapps to avoid automatic deployment. Not moving the war file for some reason causes issues ONLY with grails applications.
  7. Now just restart the tomcat using the shortcut command of or full command of /jakarta_tomcat/bin/
  8. On starting up your application should work as expected.

Tuesday, September 2, 2008

Deploying Grails on Shared and Private Tomcat

Hello All,

I intend to take all through my experience of developing a working (almost professional) website completely using Grails with a bit of Javascript sprinkled in and ample help from Dreamweaver in creating the views. There were several hurdles along the way especially considering that I am not your average Java geek. I have until recently been playing a marketing role and whatever coding I had done in the past had been in C/C++ and that too many eons back. So, if I say that Grails is easy, you better believe it. And to prove it, I have developed completely on my own with a wife and a demanding 2 and a half year old! And best of all , I was able to do this in 2 weeks development time + 1-2 week deployment (took longer than usual and hence the need for this post as I couldn't find too many resources that provided this info in sufficient detail) + a couple of days of testing. I intend to write a detailed eBook of how I went about creating Travootrr including the entire zipped source code. For now here is how you would deploy your Grails application on on a private or a shared tomcat 5.5 or 6.0:

Disclaimer: I am sure there are better ways. It's also possible that I might have not understood everything. But, I am certain that the below steps makes a grails app work!!!

Shared Tomcat:
  1. Create a war of your grails application using the "grails war" command on your local grails project directory.
  2. Upload the war file into the httpdocs directory.
  3. Login to your account ssh.
  4. This is the most important part and most people screw up here so listen closely:
  • Before you restart the server, you need to update the apache mappings for grails to work. This will be done differently in different servers but on, you need to execute the command updatevhost
  • First add "index.gsp" to the DirectoryIndex.
  • Then add the following lines:
  • "JkMount /*.gsp wXXXX" where XXXX is your port number, which you will see in the file being edited.
  • Then add, "JkMount /*.gsp/* wXXXX"
  • add, "JkMount / wXXXX"
  • add, "JkMount /* wXXXX"
  • add "JkMount /*.dispatch wXXXX"
  • add "JkMount /*.dispatch/* wXXXX"
  • add "JkMount /grails-errorhandler wXXXX"
  • add "JkMount /grails-errorhandler wXXXX"
5. Once this has been added save the above using F2 and save.
6. Now request restart of your tomcat using the command "restartsharedtomcat55" on your ssh prompt.
7. That's it. On restart, your grails application should work. If it doesn't, contact me and I will help if possible.

Private Tomcat:

Only a few steps are different here:
  1. Download the war file into your tomcat/webapps directory.
  2. Update apache mapping as above.
  3. restart tomcat using the command "jr"
  4. And that's it. Your app should be ready to go!
Remember folks. These steps are specific to Although the dropping of the war and editing apache mapping should be common on all servers that support Java, Spring and Hibernate. Many sites don't so be careful!