deploy war file without lib in Tomcat

by Hamid Reza Fahimi Madjd @ Dec 12, 2007

At this post I'd talk about how to decrease size of big war files and make deployment faster.
I have a 15 MB war file and the size of lib (jar files) directory is 14.8 MB! So I need a solution that enables me to upload my project lib directory just for once and after that deploy my war file without lib directory.


At first I renamed my lib directory to myprojlib and then copied (for example using ftp) it to ${tomcat home}/common/lib folder on the server.
After that I modify catalina.properties file in ${tomcat home}/conf and add my myprojlib path to common.loader according below:

common.loader=${catalina.home}/common/classes,
${catalina.home}/common/i18n/*.jar,
${catalina.home}/common/endorsed/*.jar,
${catalina.home}/common/lib/*.jar,
${catalina.home}/common/lib/myprojlib/*.jar

After that I remove lib folder from my project and compile it without lib directory. Be careful don't package jar files in your project. My war file is 180KB now and I deploy it easily and I shouldn’t deploy 15 MB war file every time.

java, lib, tomcat, war file

1 comment

#1. Sridhar @ 2011-10-21 12:31:11

Thanks. Well written and it saved me time .. as this is exactly what I am trying to do.

last tweet