My Octopress Blog

A blogging framework for hackers.

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:

http://www.anyware.co.uk/2005/2009/01/21/excluding-files-from-a-war-with-grails-the-right-way/

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 ->
delete(file:"${stagingDir}/WEB-INF/lib/hibernate-core-3.3.1.GA.jar")
}