Wednesday, December 26, 2007

deploy war file without lib in Tomcat

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

Now save the file and restart my Tomcat.

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.

Labels: , , ,

2 Comments:

At May 6, 2008 12:09 PM , Anonymous Anonymous said...

Thx for this very useful tip. Saved my day .

 
At July 11, 2008 4:11 PM , Anonymous roshan4uqureshi@gmail.com said...

Hi! Thanks.
It's really a good tip!

 

Post a Comment

<< Home