Thursday, March 24, 2011

Excluding jars from a Grails generated war file

Yesterday, I posted about how to upgrade hibernate versions in grails. This solution worked great for me locally. (i.e. using run-app) But we were still getting weird issues in our staging environment. It's not uncommon for this kind of thing to happen, and I used my local tomcat setup to try and nail down the problem. When I cracked open the WAR, I found two version of hibernate, 3.3.1 and 3.3.2. Upon closer inspection of the problem, it turned out to be the same original issue I had upgraded Hibernate to fix, somewhat hidden by some additional 'noise' in the log file. I tried about 10 different things to get the war to generate correctly, until I stumbled onto this blog post:

Grails gives you the option to declare a closure to modify the war resources. I added the following to the top of my buildConfig.groovy, and it fixed the issue:

grails.war.resources = { stagingDir ->


David E. Jacobs said...

thanks!and go on! love it!

srini dutt said...

This should be in the correct location. the correct location is after the tag grails.project.fork ={.......}