
Sample solution: Dispatch RMI DHTML requests in clustered server environment
This sample solution is to visit DHTML JSPs remotely from WebSphere 5.1 to JReport Enterprise Clustered Server. See the below diagram for the structure:

This demo dispatcher dispatches requests from different sessions to different JReport Enterprise Server according to Round-Robin algorithm. The dispatcher has the Fail Over function, which will periodically check whether there is any unavailable server in the cluster. No request will be dispatched to the unavailable server until the server is checked to be available again.
In general, the solution can be categorized into the below major steps:
- Set up the server cluster.
- Generate a WAR file containing DHTML RMI JSP and Dispatcher for WebSphere.
- Deploy the WAR file to WebSphere.
- Configure cluster JReport Enterprise Server.
In the following part, we will explain clearly what exact operations you are expected to make in each of the main steps.
Setting up the server Cluster
You can go to the JReport Enterprise Server Cluster chapter for the background knowledge of JReport cluster concepts and configurations.
In this example we will set up two JReport Enterprise Servers into the cluster using the Round Robin algorithm.
192.168.126.116
192.168.126.115
Refer to Setting up a JReport Enterprise Server cluster for the specific steps of setting up JReport Enterprise Server in a cluster.
Generating a WAR file containing DHTML RMI JSP and Dispatcher for Websphere
- Create a new directory in your local disk, e.g.
d:\servlet.
- Create a sub directory WEB-INF in it:
d:\servlet\WEB-INF.
- Generate a web.xml like following and put it in
d:\servlet\WEB-INF.
<?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>
<context-param>
<param-name>jrs.remote.host</param-name>
<param-value>127.0.0.1</param-value>
</context-param>
<context-param>
<param-name>jrs.remote.rmiport</param-name>
<param-value>1129</param-value>
</context-param>
<!-- The third param(jrs.rmi.auth_file) is optional.
"authFileName" includes the auth file's realpath and auth file name.
For example: C:\JReport\Server\bin\rmi.auth. The content of the auth file
specified here should be kept consistent with that of the auth file used
by JReport Enterprise Server, though there is no need to point to the same
auth file.-->
<context-param>
<param-name>jrs.rmi.auth_file</param-name>
<param-value>C:\JReport\Server\bin\rmi.auth</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>
</filter>
<filter-mapping>
<filter-name>Character Encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<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>help</servlet-name>
<servlet-class>jet.web.dhtml.JHelplet</servlet-class>
</servlet>
<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>help</servlet-name>
<url-pattern>/help/*</url-pattern>
</servlet-mapping>
</web-app>
|
- Create a directory lib in
d:\servlet\WEB-INF.
- Copy the class files JREngine.jar, JRESServlets.jar, JRWebDesign.jar, log4j-1.2.8.jar and sac.jar from
<server_install_root>\lib to d:\servlet\WEB-INF\lib.
- Create a jar file to include the resources folder which is located in server installation root and name it languages.jar. For example, run the following command:
<server_install_root>>jar -cvf languages.jar resources
Then put the jar in d:\servlet\WEB-INF\lib.
- Compile the dispatcher DemoRemoteDispatcher.java stored in
<server_install_root>\help\server\en\samples with <server_install_root>\lib\JRESServlets.jar and <server_install_root>\lib\servlet.jar. The class file DemoRemoteDispatcher.class and some other class files will be generated.
- In
d:\servlet\WEB-INF, create folder and subfolder d:\servlet\WEB-INF\classes\demodispatch and copy DemoRemoteDispatcher.class together with the other class files generated in step 7 to this folder.
- Copy all the folders in
<server_install_root>\public_html to d:\servlet. If you are not using remote administration functions you need not copy the admin folder.
- Optionally copy the folder userguide in
<server_install_root>\help\server\en to d:\servlet\help\server\en.
- Using the following command to create a WAR file, name it as servlet.war:
d:\servlet>jar -cvf servlet.war *
Deploying the WAR file to Websphere
- Start IBM WebSphere 5.1. (WebSphere 5.0 is also ok for the solution).
- Open Administrative Console. You can open Administrative Console by using the Start Menu, or by using the URL:
http://hostname:9090/admin/, where hostname is host name or IP address, and 9090 is the port number.
- After successfully log in, expand the Applications node, and then click Install New Application.
- Click Browse to select your .war file. In the Context Root field, type a context path such as /servlet/ ("/servlet" is also ok). Click Next.
- Do not check any option in this page, and then click Next.
- Type RMI_DHTML in the Application Name field. DO NOT check the Pre-compile JSP option. Click Next.
- Do not make any changes in the next two pages.
- Click Finish in the Summary page. The installing process may take several minutes, wait until the process is completed.
- After the installation process is completed, click Save to Master Configuration. Then in the Save to Master Configuration dialog, click Save.
- This step is to configure the dispatcher and cluster server. Go to WebSphere Admin Control to add some properties for this dispatcher. Expand Servers, go through Application Servers > Server1 > Process Definition (in the Additional Properties table) > Java Virtual Machine > Custom Properties (in the Additional Properties table).
Click the New button to add properties for our demo dispatcher com.jinfonet.dispatcher.configFile and jrs.remote.dispatcher.

Note that the the dispatcher DemoRemoteDispatcher.java will read the clustered server information in the hostport.conf file like below:
rmiserver=192.168.126.116:1129
rmiserver=192.168.126.115:1130
...
- If you have set up JReport Enterprise Server in a cluster, you can append their host and port information to the above text file.
- Click Save link in Message(s) table and click Save button to save the changes, and then restart WebSphere5.1.
Configuring Cluster JReport Enterprise Server
- Make sure JReport Enterprise Server has been started once in order that the server.properties file is generated.
- Change server.properties file in
<server_install_root>\bin as follows:
server.rmiserver.enable=true
server.rmiadminservice.enable=true
Then you can start JReport Enterprise Server and access DHTML with the following URL:
http://hostname:9080/servlet/dhtmljsp/dhtml.jsp?jrs.report=/SampleReports/EmployeeInformation.cls&jrs.catalog=/SampleReports/SampleReports.cat&
jrs.path=/SampleReports/EmployeeInformation.cls
