<?xml version="1.0" encoding="UTF-8"?>
<section version="5.0" 
         xmlns="http://docbook.org/ns/docbook" 
         xmlns:xlink="http://www.w3.org/1999/xlink" 
         xmlns:xi="http://www.w3.org/2001/XInclude" 
         xmlns:svg="http://www.w3.org/2000/svg" 
         xmlns:mml="http://www.w3.org/1998/Math/MathML" 
         xmlns:html="http://www.w3.org/1999/xhtml" 
         xmlns:db="http://docbook.org/ns/docbook" 
         xml:lang="en" 
         xml:id="web.packaging">

  <info><title>WAR Packaging</title></info>
    
    <para>
      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.
    </para>
    <para>
      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:
    </para>
    <itemizedlist>
      <listitem><para>
        web.xml
        : The standard xml deployment descriptor in the format     defined in the Java Servlet 2.4 Specification. Refer to     
        $JONAS_ROOT/xml/web-app_2_4.xsd
        .
      </para></listitem>
      <listitem><para>
        jonas-web.xml
        : The optional JOnAS-specific XML deployment     descriptor in the format defined in     
        $JONAS_ROOT/xml/jonas-web_X_Y.xsd
        .
      </para></listitem>
      <listitem><para>
        classes
        : a directory that contains the servlet classes and     utility classes.
      </para></listitem>
      <listitem><para>
        lib
        : a directory that contains jar archives of libraries (tag     libraries and any utility libraries called by server-side classes). If     the Web application uses Enterprise Beans, it can also contain     
        ejb-jars
        . This is necessary 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
         must not be placed here. In this case, they are directly     included in the 
        ear
        . Due to the use of the class loader hierarchy,     Web components have the visibility of the EJB classes.
             Details about the class loader hierarchy are described in 
        <link xlink:href="j2eeprogrammerguide.html#j2ee.pg.classloader">
          JOnAS class loader     hierarchy
        </link>
        .
      </para></listitem>
    </itemizedlist>
    <section><info><title>Example</title></info>
      
      <para>
        Before building a 
        war
         file, the java source files must be compiled to obtain the class files (located in the 
        WEB-INF/classes
         directory) and the two XML deployment descriptors must be written.
      </para>
      <para>
        Then, the 
        war
         file (&lt;web-application&gt;.war) is built using the 
        jar
         command:
      </para>
      <screen>
    cd &lt;your_webapp_directory&gt;
    jar cvf &lt;web-application&gt;.war *</screen>
      <para>
        During the development process, an 'unpacked version' of the war file can be used. Refer to 
        <link xlink:href="configuration_guide.html#N10791">
          Configuring Web Container Service 
        </link>
        for information about how to use directories for the web application.
      </para>
    </section>
  </section>