BackPrevious Page Next PageNext

Building a WAR/EAR file to Include a Self-contained JReport Server

Building a JReport Server WAR/EAR by tool

Building a JReport Server WAR manually (deprecated)

There are two ways of creating a WAR or EAR to include a self-contained JReport Server:

The self-contained JReport Server is based on a library. The library contains all class packages required by the JReport Server runtime, such as jrenv.jar, JRESServlets.jar, JREngine.jar, and JRWebDesign.jar. In the library, jrenv.jar contains the entire JReport runtime environment, and is the key to the self-contained integration solution. With the self-contained solution, the WAR/EAR file can be deployed to any Java EE compliant application server without having to specify a JReport Server installation root as the reporthome.

Before generating the WAR/EAR file, you can customize the reporthome and data source for JReport Server if necessary, or use the default settings. For details about specifying the data source for JReport Server in a Java EE environment, see Configuring the Server Database in an Integrated Environment.

Note: There is a parameter in self-contained WAR/EAR - autoDetectServletPath. It is used to dynamically detect and modify servlet path based on context path of self-contained WAR/EAR when deploying the WAR/EAR to a J2EE application server. This property is enabled by default, and the actual servlet path will be concatenating "context path" with "default servlet path" set in server.properties. If you do not want this way, you can disable the feature using either of the following ways:

Building a JReport Server WAR/EAR by tool

The tool makewar.bat/makewar.sh in <install_root>\bin based on the Apache Ant project is provided by JReport Server to build JReport Server WAR/EAR file which contains the full JReport Server runtime environment. The file makewar.xml in the same directory can be used to specify information needed for building the WAR/EAR file.

When you create a JReport Server WAR/EAR file using the tool, the jrenv.jar package will be automatically put into the WAR/EAR, and will be extracted to the specified reporthome when initializing JReport Server. The following is the structure of the jrenv.jar package:

jrenv.jar

The bin/, lib/, and template/ folders are necessary for the JReport runtime, while the profiling/, jreports/, db/ and help/ folders are optional.

The following shows the usages of makewar.xml and makewar.bat/makewar.sh in detail.

makewar.xml

This file can be used to specify the following:

makewar.bat/makewar.sh

The batch/script file used to build a JReport Server WAR/EAR according to the target specified in makewar.xml.

Usage

makewar.bat/makewar.sh [Target Name] [-Dpredeploy=ReportFolder] [-Dreporthome=XXX] [-Djrs.remote.host=XXX] [-Djrs.remote.rmiport=XXX] [-Djrs.rmi.auth_file=XXX]

Options

Examples

Building a JReport Server WAR manually (deprecated)

This method 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.

The following takes creating a WAR file manually on Unix for example. It is assumed that JReport Server has been installed to /opt/JReport/Server. 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.

If you want to make the WAR include a self-contained JReport Server, you need create jrenv.jar and then put it in the jreport/WEB-INF/lib directory before creating the WAR. You can use either way to create jrenv.jar:

Then 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,.png,.svg,.pdf,.rtf,.xls,.xml,.xlsx,.gif,.ico,.rpt,.cls,.jpg,.jpeg,.zip,.jz</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>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>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-1.1.3.jar, jai_core-1.1.3.jar, JREngine.jar, JRESServlets.jar, JRWebDesign.jar, languages.jar, sac-1.3.jar, tar.jar, log4j-core-2.7.jar and log4j-api-2.7.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

      • 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 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 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.7.0_17/bin/jar.exe.

BackPrevious Page Next PageNext