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="ISO-8859-1"?> 
    <!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>
        <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>help</servlet-name>
            <servlet-class>jet.web.dhtml.JHelplet</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>help</servlet-name>
            <url-pattern>/help/*</url-pattern> 
        </servlet-mapping>
    
    </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:

  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:

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