This post originated from an RSS feed registered with Java Buzz
by Simon Brown.
Original Post: WAR files : to explode or not?
Feed Title: Simon Brown's weblog
Feed URL: http://www.simongbrown.com/blog/feed.xml?flavor=rss20&category=java
Feed Description: My thoughts on Java, software development and technology.
In Stop the pollution in WEB-INF/classes, Sebastiano talks about the proliferation of configuration files underneath the /WEB-INF/classes directory of Java EE web applications. It's an interesting post and I like the recommendation of placing configuration files in a separate directory. However, it was the first comment that sparked me to write this blog entry.
WAR files are used a lot, in my experience, far more than exploded directories.
Personally, I'm starting to use WAR files for deployment much less than I ever used to, and this is exactly because of the reasons outlined in Sebastiano's blog entry. Now, I prefer to keep the exploded web application directory structure outside of the web container installation and simply link to it instead (e.g. using a separate Tomcat context definition). Problems with throwing a single deployable unit at a web container installation include...
Configuration can't be tweaked if needed (e.g. log levels).
Application patches are harder to apply.
Web container upgrades are more complex.
There's also something more fundamental. Back in the good old days of J2EE, it was quite common to see configuration defined at the application/web server level, utilising JNDI for example. Now, frameworks are pushing configuration back into the web application because it does make for applications that are easier to port between containers. You just have to take a look at Spring and Acegi for examples of how database and security configuration can now reside alongside the webapp, in a container independent way.
This has some interesting consequences, particularly if you need to hand-off a web application to a separate team for deployment into production. Typically, development doesn't have access to the production configuration (e.g. database credentials) so providing an exploded webapp tends to make installation/deployment/customisation an easier process, regardless of whether it's manual or automated.
I'm curious, what's your preference - a WAR file or its exploded form?