Halley's Blog

Removing Conflicting jar files from Grails

Posted in Grails, Technical by Halley on June 28, 2014

Last week, we were trying to deploy a Grails application to a Websphere 8.5 Server. Everything went well till the deployment. After deployment, all hell broke loose. Our application was throwing

java.lang.VerifyError: JVMVRFY007
java.lang.VerifyError. Message: JVMVRFY007 final method overridden;

We were at our wits end as to what was going wrong. And finally, Google threw out the problem and the solution. There is a small problem with WAS v8.5.1 which causes some compatibiltiy issues with certain classes. In our case, the culprit was cglib-2.2.jar.

For those curious souls out there, here is the link from which we found our problem and the solution also.

So, the simple solution was to replace the cglib-2.2.jar file with cglib-nodep.jar which will not use any of the problem causing jar files exposed by WAS. But the million dollar question was, HOW…!

Enter the configuration option in Grails, grails.war.resources. This lets you do any extra processing you want before the WAR file is finally created.

So, here is our recipe.

grails.war.resources = { stagingDir, args ->
       println "Removing cglib-2.2.jar from WEB-INF/lib/"
       delete(file: "${stagingDir}/WEB-INF/lib/cglib-2.2.jar")

dependencies {
              compile 'cglib:cglib-nodep:2.2'

Groovy, isn’t it?