tags:

views:

25

answers:

1

Hi guys,

I am doing some research in the way i can deploy an application efficiently using a war file. What i currently do is i deliver the war file everytime there is a release.

This means everytime there is a change no matter how small the change is i have to build and deliver all files that make up the application. I am thinking that maybe this is not the correct way to do this.

For example if there is a change to a css file i have to rebuild the war file which will include all file. This includes recompiling all *.java files as well.

In the above example, is it possible to build a war file with just the css file and deploy it to the tomcat server and have Tomcat just replace the css file and leave everything else as is?

+3  A: 

You can do an "exploded" deployment which is just the war file unzipped. Then you can update the individual files. For that you place the "unpacked" directory where you would want to have the war file. If you use tomcat and look in the deploy directory, you'll see that that is what tomcat does anyway.

It is not guaranteed that the changes will be picked up though. CSS files and images and o forth should pose no problems, but JSP, template files etc tend to be compiled and cached and you have to do some config magic to have the app replace these artifacts. Typically this comes at a performance cost and may lead to the Dreaded PermGen Errors when classes are replaced but not freed from memory. If you do this, make sure you bounce your server regularly at a good moment, and keep an eye on the PermGen memory area with virtualvm or jconsole or similar tool.

Peter Tillemans
When you mentioned the deploy directory did you mean the "webapps" directory Tomcat?What exactly would cause the PermGen errors? I thought that if you replace a class with a new one it will just be replaced?If i make a war file with just one file in it will tomcat delete the existing folder? (I should try this myself!)
ziggy
Classes are moved to the Permanent Generation which is by default not swept for cleaning. So classes which are swapped out will not lead to releasing the memory in the PermGen. If you create a war with a single file in it it will delete the complete exploded folder if I remember correctly. It is a lot easier to simply drop the files in place. Certain file trigger a complete site redeployment, web.xml I think. Well at least in JBoss it does this.
Peter Tillemans
I have to try the web.xml deployment as that would mean that if web.xml is deployed everything else will have to be re-deployed.
ziggy