### Building a JReport Server WAR manually (deprecated)

This section introduces a method that has been used in earlier versions. If using this method, you will have to specify the JReport Server installation root as the reporthome unless you make the WAR be a self-contained solution.

This section takes creating a WAR file on Unix for example. The instruction is applicable to both Unix and Windows platforms. However, the paths for Windows should use the Windows format, for example, `C:\JReport\Server`, while paths for Unix should use the Unix format, for example, `/opt/JReport/Server`.

It is assumed that JReport Server has been installed to `/opt/JReport/Server`.

Take the following steps to build a JReport Server WAR manually:

1. Create a new directory jreport in the JReport Server installation root: `/opt/JReport/Server/``jreport`.
2. Create a sub directory WEB-INF in jreport: `/opt/JReport/Server/jreport/WEB-INF`.
3. Create a web.xml file in the WEB-INF directory as follows:

       <?xml version="1.0" encoding="UTF-8"?>
       <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">

       <web-app>

           <!--By default JReport server detect servlet path-->
           <!--
           <context-param>
           <param-name>autoDetectServletPath</param-name>
           <param-value>false</param-value>
           </context-param>
           -->

           <filter>
               <filter-name>Character Encoding</filter-name>
               <filter-class>jet.server.servlets.CharacterEncodingFilter</filter-class>
               <init-param>
                   <param-name>encoding</param-name>
                   <param-value>UTF-8</param-value>
               </init-param>
               <init-param>
                   <param-name>excludedFiles</param-name>
                   <param-value>.css,.js</param-value>
               </init-param>
           </filter>

           <filter>
               <filter-name>JzFileFilter</filter-name>
               <filter-class>com.jinfonet.web.client.RespHeaderFilter</filter-class>
               <init-param>
                   <param-name>Content-Type</param-name>
                   <param-value>application/x-javascript</param-value>
               </init-param>
               <init-param>
                   <param-name>Content-Encoding</param-name>
                   <param-value>gzip</param-value>
               </init-param>
           </filter>

           <filter-mapping>
               <filter-name>JzFileFilter</filter-name>
               <url-pattern>*.jz</url-pattern>
           </filter-mapping>

           <filter-mapping>
               <filter-name>Character Encoding</filter-name>
               <url-pattern>/*</url-pattern>
           </filter-mapping>

           <listener>
               <listener-class>jet.server.servlets.JRServerContextListener</listener-class>
           </listener>

           <servlet>
               <servlet-name>jrserver</servlet-name>
               <servlet-class>jet.server.servlets.JRServlet</servlet-class>
           </servlet>

           <servlet>
               <servlet-name>sendfile</servlet-name>
               <servlet-class>jet.server.servlets.SendFileServlet</servlet-class>
           </servlet>

           <servlet>
               <servlet-name>dhtml</servlet-name>
               <servlet-class>jet.web.dhtml.DHTMLlet</servlet-class>
           </servlet>

           <servlet>
               <servlet-name>jrdhtml</servlet-name>
               <servlet-class>jet.web.dhtml.DHTMLRunReportlet</servlet-class>
           </servlet>

           <servlet>
               <servlet-name>WebOSServlet</servlet-name>
               <display-name>WebOSServlet</display-name>
               <servlet-class>com.jinfonet.web.client.WebOSServlet</servlet-class>
           </servlet>

           <servlet-mapping>
               <servlet-name>jrserver</servlet-name>
               <url-pattern>/jrserver/*</url-pattern>
           </servlet-mapping>

           <servlet-mapping>
               <servlet-name>sendfile</servlet-name>
               <url-pattern>/sendfile/*</url-pattern>
           </servlet-mapping>

           <servlet-mapping>
               <servlet-name>dhtml</servlet-name>
               <url-pattern>/dhtml/*</url-pattern>
           </servlet-mapping>

           <servlet-mapping>
               <servlet-name>jrdhtml</servlet-name>
               <url-pattern>/jrdhtml/*</url-pattern>
           </servlet-mapping>

           <servlet-mapping>
               <servlet-name>WebOSServlet</servlet-name>
               <url-pattern>*.do</url-pattern>
           </servlet-mapping>

           <servlet-mapping>
               <servlet-name>WebOSServlet</servlet-name>
               <url-pattern>*.vt</url-pattern>
           </servlet-mapping>

           <servlet-mapping>
               <servlet-name>WebOSServlet</servlet-name>
               <url-pattern>/vt/*</url-pattern>
           </servlet-mapping>

           <welcome-file-list>
               <welcome-file>index.htm</welcome-file>
               <welcome-file>index.html</welcome-file>
               <welcome-file>index.jsp</welcome-file>
           </welcome-file-list>

           <!-- Define J2EE DataSource resource ref -->
           <!--
           <resource-ref>
               <description>
                   Define J2EE DataSource resource for JReport server DB 'systemtables'.
               </description>
               <res-ref-name>jdbc/ds-jreport-systemtables</res-ref-name>
               <res-type>javax.sql.DataSource</res-type>
               <res-auth>Container</res-auth>
           </resource-ref>
           -->

           <!--
           <resource-ref>
               <description>
                   Define J2EE DataSource resource for JReport server DB 'realmtables'.
               </description>
               <res-ref-name>jdbc/ds-jreport-realmtables</res-ref-name>
               <res-type>javax.sql.DataSource</res-type>
               <res-auth>Container</res-auth>
           </resource-ref>
           -->

           <!--
           <resource-ref>
               <description>
                   Define J2EE DataSource resource for JReport server DB 'profile'.
               </description>
               <res-ref-name>jdbc/ds-jreport-profiling</res-ref-name>
               <res-type>javax.sql.DataSource</res-type>
               <res-auth>Container</res-auth>
           </resource-ref>
           -->

           <login-config>
               <auth-method>BASIC</auth-method>
           </login-config>

           <!-- Notify JReport server to use J2EE DataSource -->
           <!--
           <env-entry>
               <description>
                   Notify JReport server DB 'systemtables' to use J2EE DataSource.
               </description>
               <env-entry-name>jreport.datasource.systemtables</env-entry-name>
               <env-entry-value>jndi://jdbc/ds-jreport-systemtables</env-entry-value>
               <env-entry-type>java.lang.String</env-entry-type>
           </env-entry>
           -->
           <!--
           <env-entry>
               <description>
                   Notify JReport server DB 'realmtables' to use J2EE DataSource.
               </description>
               <env-entry-name>jreport.datasource.realmtables</env-entry-name>
               <env-entry-value>jndi://jdbc/ds-jreport-realmtables</env-entry-value>
               <env-entry-type>java.lang.String</env-entry-type>
           </env-entry>
           -->
           <!--
           <env-entry>
               <description>
                   Notify JReport server DB 'profile' to use J2EE DataSource.
               </description>
               <env-entry-name>jreport.datasource.profiling</env-entry-name>
               <env-entry-value>jndi://jdbc/ds-jreport-profiling</env-entry-value>
               <env-entry-type>java.lang.String</env-entry-type>
           </env-entry>
           -->

           <!-- Specify report home or customized server environment callback -->
           <env-entry>
               <description>
                   Specify report home for JReport server directly.
               </description>
               <env-entry-name>jreport.rpthome</env-entry-name>
               <env-entry-value>/home/Jetty9WarHome</env-entry-value>
               <env-entry-type>java.lang.String</env-entry-type>
           </env-entry>

           <!--
           <env-entry>
               <description>
                   Specify customized server environment callback for Jreport server.
               </description>
               <env-entry-name>jreport.servenv</env-entry-name>
               <env-entry-value>jet.server.DefaultServerEnv</env-entry-value>
               <env-entry-type>java.lang.String</env-entry-type>
           </env-entry>
           -->

       </web-app>

4. Create a directory lib in the `jreport/WEB-INF` directory:

   `mkdir lib`

5. Create a directory pages in the `jreport/WEB-INF/lib` directory:

   `mkdir lib/pages`

6. Copy all of the files in `/opt/JReport/Server/lib/pages` to the `jreport/WEB-INF/lib/pages` directory:

   `cp /opt/JReport/Server/lib/pages/* lib/pages`

7. Create a jar file to include the resources folder which is located in `/opt/JReport/Server` and name it languages.jar. For example, run the following command:

   `jar -cvf languages.jar resources`

   Then put the languages.jar in `/opt/JReport/Server/lib`.

8. Copy the following jar files from `/opt/JReport/Server/lib` to the `jreport/WEB-INF/lib` directory: commons-codec-1.2.jar, jai_codec.jar, jai_core.jar, JREngine.jar, JRESServlets.jar, JRWebDesign.jar, languages.jar, log4j-1.2.8.jar, sac.jar, tar.jar, xercesImpl.jar, xml-apis.jar.

   If you want to export reports to the following formats, you should copy the corresponding jar to the `jreport/WEB-INF/lib` directory:

   - To e-mail or use the e-mail Notification function, copy activation-1.1.jar and mail-1.4.jar.
   - To FTP, copy commons-net-ftp-2.0.0.jar.
   - To PDF and Page Report Result, copy itext_1.5.4.jar.
   - To Excel, copy poiHSSF_151.jar.
9. Copy the index.htm file and the admin, dhtmljsp, images, javascript, jinfonet, skin, and style folders from `/opt/JReport/Server/public_html` to the `/opt/JReport/Server/jreport` directory:

   `cp -r /opt/JReport/Server/public_html/* /opt/JReport/Server/jreport`

   Notes:

   - The jsp files within the admin folder are used by the JReport Administration pages. Those within the dhtmljsp folder are used when viewing reports in Page Report Studio.
   - If you copy index.htm and these folders mentioned above to a sub folder in `/opt/JReport/Server/jreport`, for example, `/opt/JReport/Server/jreport/sub`, to view reports in Page Report Studio, you need:
     - Modify the server.properties file:

       `web.skin.dir=/jreport/sub/skin`

     - Uncomment the following lines in dhtml.jsp in the dhtmljsp folder and make it adapt to the environment as follows:

       `dhtmlConfig.setDHTMLContextPath(SessionID,"http://localhost:8080/jreport/sub");
       dhtmlConfig.setDHTMLJspUrl(SessionID,"/jreport/sub/dhtmljsp/");
       dhtmlConfig.setDHTMLServletUrl(SessionID, RptSetId, "/jreport/dhtml");`

     - In the step 10, edit the index.htm file like this:

       `<FRAME name="ind" src="/jreport/sub/jinfonet/index.jsp" frameborder="0">`

     Then go to step 11.

10. Edit the index.htm file and add the context path `/jreport` to the src tag. Note that the path separator character is the Unix style "/" when referencing JSP. The result should be as follows:

    `<FRAME name="ind" src="/jreport/jinfonet/index.jsp" frameborder="0">`

11. If you are going to create the war for use in Weblogic, you need to check whether there is a weblogic.xml in the `jreport/WEB-INF` directory. If yes, make sure the following line is added in the weblogic.xml:

    `<show-archived-real-path-enabled>true</show-archived-real-path-enabled>`

    If no, create a weblogic.xml and add it in the `jreport/WEB-INF` directory. The content in the weblogic.xml looks like:

        <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE   weblogic-web-app PUBLIC "-//BEA Systems, Inc.//DTD Web Application 8.1//EN"
        "http://www.bea.com/servers/wls810/dtd/weblogic810-web-jar.dtd">

        <weblogic-web-app>
            <container-descriptor>
            <show-archived-real-path-enabled>true</show-archived-real-path-enabled>
            </container-descriptor>
        </weblogic-web-app>

12. Using the following command to create a WAR file named jreport.war:

    `jar -cvf jreport.war index.htm admin dhtmljsp images javascript jinfonet skin style WEB-INF`

    Note: The jar utility is in the Java home bin directory. If it is not on your path you must call jar with the entire path, for example, `/opt/jdk1.6.0_17/bin/jar.exe`.

#### To make the WAR be a self-contained solution

To make the WAR include a self-contained JReport Server, except for the above procedure, you need create jrenv.jar and then put it in the `jreport/WEB-INF/lib` directory before creating the WAR.

Use either way to create the jrenv.jar:

- By the makewar.bat/makewar.sh tool
  For example: run the command `makewar jrenv.jar`
- Creating manually
  Make sure all necessary contents are included and then use a proper tool to package them into a jar file.

See also Building a WAR/EAR file to include a self-contained JReport Server for details about the structure of the jrenv.jar.