Pattern - WAR Files
WAR files are a common deployment format in Java, a means of bundling code and HTML into one package.
Features
- A web application is built from static (.html, .xhtml) and dynamic (.jsp, .jspx .do and others) pages
- Java code can contain servlets, SOAP-based Web Services and other dynamic handlers of HTTP requests. These
are implemented in libraries, or in classes stored in WEB-INF/classes in the zip file
- The Web Application Deployment Descriptor WEB-INF/web.xml can contain configuration information, including a list of servlets, and runtime options.
- Libraries can be added to WEB-INF/lib.
Advantages
- It is a format supported by all the Java application/web servers.
- Build tools support WAR files.
- IDEs support creating WAR files.
- Integrates library distribution with static and dynamic web pages.
- A single file to distribute.
Disadvantages
- Some application servers (notably JBoss) implement radically different classloading rules.
- Build time is too early to hard code all configuration options into the Web Application Deployment Descriptor. This leads to practises such as Post-Installation Configuration File Editing
- The [Java Endorsed Directories] situation makes it impossible to bundle updates to endorsed libraries inside a WAR File; you need to include and deploy these through some other mechanism.
- The application server may need JDBC drivers, logging extensions and other extensions to common APIs/libraries to be packaged outside the WAR, and inserted into the application's classpath such that they are shared amongst all Web Applications.
- The time to build and deploy a WAR file increases with the size of the application, especially the number of embedded libraries. The more libraries you use, the longer it takes to iterate through a build/deploy/test cycle.
SmartFrog support
- Our sf-www components can deploy WAR files on any application server that we support, either directly or via Deploy by Copy.
- We have considered the concept of Deploy-Time Web Application creation. As a solution to some of the inflexibility issues.
- Our Deploy by Copy component can be used to copy in JDBC Drivers, endorsed libraries and other critical libraries in a functionanl web application into the correct locations for a specific Application Server. This can address some of the classloader limitations of the WAR file.