# WAR Packaging

## Target Audience and Content

The target audience for this guide is the Web component provider, i.e. the person in charge of developing the web components on the server side. It describes how the web components should be packaged.

The content of this guide is the following:

1. Target Audience and Content
2. Principles

## Principles

Web components are packaged for deployment in a standard Java programming language Archive file, called a war file (Web ARchive), which is a jar similar to the package used for Java class libraries. A war has a specific hierarchical directory structure. The top-level directory of a war is the document root of the application.

The document root is where JSP pages, client-side classes and archives, and static web resources are stored. The document root contains a subdirectory called WEB-INF, which contains the following files and directories:

- web.xml: The standard xml deployment descriptor in the format defined in the Java Servlet 2.3 Specification. See $JONAS_ROOT/xml/web-app_2_3.dtd.
- jonas-web.xml: The optional JOnAS specific xml deployment descriptor in the format defined in $JONAS_ROOT/xml/jonas-web_X_Y.dtd.
- classes: a directory which contains the servlet classes and utility classes.
- lib: a directory which contains jar archives of libraries (tag libraries and any utility libraries called by server-side classes). It may also contain ejb-jars if the Web application uses Enterprise Beans. This is necessary in order to give to the Web components the visibility of the EJB classes.
  However, if the war is intended to be packed in a ear, the ejb-jars are not to be placed here. In this case, they are directly included in the ear. Web components have the visibility of the EJB classes, which is due to the use of the class loader hierarchy.
  Details about the class loader hierarchy should be found at JOnAS class loader hierarchy.

### Example

To build a war file, the java source files should have been compiled to obtain the class files (located in the WEB-INF/classes directory) and the two XML deployment descriptors should have been written.

Then, the war file (<web-application>.war) is built, using the jar command:

        cd <your_webapp_directory>
        jar cvf <web-application>.war *