Creating slim Grails war file using common jars in Tomcat

124 Views Asked by At

The generated Grails war file with all default jars is around 30 MB. I need to reduce this size for frequent test deployments to remote tomcat container. So I am trying to use the common libs Tomcat technique. The process is not working for some reason.

Here are the steps I am taking

  1. First I copied all jar files from web-inf/lib directory to the server's common directory as shown below

enter image description here

Here is /var/lib/tomcat7/conf/catalina.properties common.loader configuration.

enter image description here

  1. I then configured the Grails configuration as follows

enter image description here

  1. I then create war using grails war --nojars

The generated war file was 6.42 mb.

  1. Then I copied the war file to tomcat webapps directory.

  2. When I access the webapp, I get "Page can't be found 404 error".

What am I doing wrong?

Update

Here is the error logged in catalina.out. The application was nojars.

enter image description here

1

There are 1 best solutions below

2
Orubel On

Your best bet is to limit the dependencies; this can only be done through your build.gradle file AFAIK. Cut out the cruft to only what you need.

If you know a plugin is provided by another dependency, use 'provided'

provided 'org.grails.plugins:cache:4.0.0'
compile "org.grails.plugins:async"
provided "org.grails:grails-logging"
provided "org.grails:grails-plugin-i18n"

Also, cut out double includes (like groovy-all) and other piecs you don't need:

provided 'org.codehaus.gpars:gpars:1.2.1', {
    exclude group:'org.multiverse', module:'multiverse-core'
    exclude group:'org.codehaus.groovy', module: 'groovy-all'
}

Specifically declare the pieces that you need in your gradle.build and exclude the pieces you don't. You have to be smarter about the build is all.