Glassfish Enterprise v2.1 with HADB Setup on Windows 2003 Cluster
Environment Setup
At this point you should already have 2 identical windows 2003 servers running, for this tutorial I will refer to them as SERVER1 and SERVER2. Each server should have 2 NICs. Make sure the default gateway is the SAME on all NICs. For clarification you will be using a total of 5 IP addresses. Two for each server, and one will be the virtual IP to reference the cluster. Though yours will likely be different, for this tutorial I will use 192.168.1.2 for the virtual IP, 192.168.1.3 and 192.168.1.103 for SERVER1, and 192.168.1.4 and 192.168.1.104 for SERVER2. Make sure your web address (if you have one) resolves to your virtual IP (192.168.1.2 here).
Network Load Balancing
You will need two identical windows 2003 servers. Keep in mind that as there are two NICs in each server, it does not matter which network connection you use for the network load balancing, just make sure to only load balance one. I chose to load balance 192.168.1.3 and 192.168.1.4.
- In Network Connections right click one of the LAN connections and select properties.
- Verify Network Load Balancing present and checked, if not you may need to add it by clicking Install.
- Select Network Load Balancing and click properties
- Enter the Virtual IP address to be associated with both servers.
- For Cluster operation mode select Multicast.
- For host parameters set the machines IP and subnet.
- For port rules use all the defaults.
- Click ok, select Internet Protocol (TCP/IP) and click properties
- Click advanced
- Under IP addresses make sure both the server IP and the virtual IP is listed.
- Repeat above for both servers.
Java Setup
I would assume since we are setting up a java server you are at least familiar with setting up java and may already have it installed. However for completeness I have outlined the exact setup I used.
Sun’s JAVA 1.6 JDK should be setup on both servers. You can download it from http://java.sun.com. You can likely just use the latest version, as of this writing that was 1.6.15. I installed the jdk to the default location: C:\program files\java\jdk1.6.0_15 and the JRE to C:\program files\java\jre6. Then create an environmental variable JAVA_HOME with the value C:\Program Files\Java\jdk1.6.0_15. Add C:\program files\java\jdk1.6.0_15\bin to the PATH environmental variable.
IIS Install
IIS setup is trivial. In windows use the “Add a Role” on both servers to install IIS. In IIS Manager (found in administrative tools) right click on the default website, go to properties and enter in the virtual IP address and fully qualified domain name for the description. To verify it works try accessing http://localhost. If it doesn’t come up the first thing you should check are the permissions. Check the user account used for anonymous access. Once both servers are setup you then should be able to access IIS’s “Under Construction” page from the virtual ip, in this tutorial: http://192.168.1.2/.
Glassfish setup
Make sure you download Glassfish Enterprise Server v2.1 with HADB. At the time of this writing you can find it here.
A. Complete the following setup on SERVER1 only:
- Open the setup file. Click next.
- The agreement will come up, complete that and click next again.
- For installation Directory leave the default C:\Sun\AppServer.
- Click next, if prompted select “create directory”. It should now ask you for “Component Selection”.
- Select all of the check boxes in the Server Tier: Node Agent, High Availability Database Server, and Load Balancing Plugin.
- Under Administration Select the first option: Domain Administration Server and Administration Tool.
- Make sure Sample Applications is checked under Additional.
- Click Next to go to “Java Configuration”. Select Reuse existing Java 2 SDK. It should automatically then say C:\Program Files\Java\jdk1.6.0_15.
- Click Next to go to “Web Server Location”. Select Microsoft IIS 5.0 or above.
- Click Next. It will prompt you to setup the load balance plug in, select OK.
- You should now be on “Admin Configuration”. Type in a password and master password. Set HTTP port to 8080 and HTTPS to 8433.
- Click Next to go to “Installation Options” Do not enable the update center client. Do not Create Windows Service, we will set this up later.
- Click Next and Complete the installation.
B. IIS Redirector
Open IIS Manager.
- Right click the default website and click properties.
- Select the ISAPI filter tab.
- Click Add
- Filter Name: Application Server
- Executable: C:\Inetpub\wwwroot\sun-passthrough\sun-passthrough.dll
- In the default website create a new virtual directory
- Alias: sun-paththrough
- Directory: C:\Inetpub\wwwroot\sun-passthrough
- Under Permissions check Execute
- Make sure the following is set for the PATH environmental variable:
- C:\Inetpub\wwwroot\sun-passthrough;C:\Sun\AppServer\lib;C:\Sun\AppServer\bin;C:\Program Files\Java\jdk1.6.0_15\bin
- Right click Web Service Extensions and Select ADD
- Name: Sun-Passthrough
- File: C:\Inetpub\wwwroot\sun-passthrough\sun-passthrough.dll
- Check set status to allowed
- Create the file: C:\Inetpub\wwwroot\sun-passthrough\lb.log
- Modify the permissions on the file so the group IIS_WPG has write and modify.
- Reboot your server.
C. Start the Node Agent and Admin Server.
- This can be achieved by going to Start -> Program Files -> Sun
- Start both the admin server and node agent. You will be prompted for the passwords you entered during setup.
D. Install glassfish on SERVER2
Repeat steps A through C above with the following exceptions:
- In the “Component Selection” of the glassfish install selection No Administration Tools
- Setup will ask you to specify the admin host. Use SERVER1′s IP: 192.168.1.3
Glassfish Cluster
By now the domain admin server should be running on SERVER1 and the Node agents should be running on SERVER1 and SERVER2. Now we will create the glassfish cluster, with two instances on each physical server.
- login to the Admin Console found at https://localhost:4848/ on SERVER1
- Select Clusters, then click New
- For the name of the cluster I used application_cluster
- under instances select new, call the instance app1, give it a weight of 100, and select SERVER1 as the node.
- create 3 more instances, app2, app3, and app4, all with a weight of 100. Make sure app3 and app4 user SERVER2 for their nodes.
HTTP Load Balancer
Now we need to setup the load balancer. This piece is essentially the map from IIS to glassfish. It is an xml file that will need to be updated every time you add a new application to the server, or add additional glassfish instances to the cluster. The admin console will build it for you, all is needed is to copy it over to IIS.
- In the admin console select “HTTP Load Balancers”.
- Click New. Enter applicationlb for the name, localhost for IP and 80 for port.
- The port and IP here are actually irrelevant as glassfish does not support auto updating the loadbalancer with IIS.
- Add application_cluster as the selected target

- Click ok. Click on applicationlb you just created and select the Export tab, then click Export Now.
- If you get the following error: The XML page cannot be displayed, right click and select view source.
- You need to create the file loadbalancer.xml at C:\Inetput\wwwroot\sun-passthrough\ and save the contents to this file. The file must be saved on BOTH servers. Afterward restart IIS on both machines and restart the glassfish cluster. You can see an example of my loadbalancer.xml below:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE loadbalancer PUBLIC "-//Sun Microsystems Inc.//DTD Sun Java System Application Server 9.1//EN" "sun-loadbalancer_1_2.dtd">
<loadbalancer>
<cluster name="application_cluster" policy="round-robin">
<instance disable-timeout-in-minutes="30" enabled="true" listeners="http://SERVER1:38080 https://SERVER1:38181" name="app_2" weight="100"/>
<instance disable-timeout-in-minutes="30" enabled="true" listeners="http://SERVER1:38081 https://SERVER1:38182" name="app_1" weight="100"/>
<instance disable-timeout-in-minutes="30" enabled="true" listeners="http://SERVER2:38080 https://SERVER2:38181" name="app_3" weight="100"/>
<instance disable-timeout-in-minutes="30" enabled="true" listeners="http://SERVER2:38081 https://SERVER2:38182" name="app_4" weight="100"/>
<health-checker interval-in-seconds="30" timeout-in-seconds="10" url="/"/>
</cluster>
<property name="response-timeout-in-seconds" value="60"/>
<property name="reload-poll-interval-in-seconds" value="60"/>
<property name="https-routing" value="true"/>
<property name="require-monitor-data" value="false"/>
<property name="last-exported" value=""/>
<property name="active-healthcheck-enabled" value="false"/>
<property name="number-healthcheck-retries" value="3"/>
<property name="rewrite-location" value="true"/>
</loadbalancer>
<!--
This file was generated on: [Wed Aug 26 00:54:11 GMT-10:00 2009].
Debugging Tips:
By default, instances and web-modules are not enabled. Please enable them manually if you have not done that using asadmin.
-->
HADB Setup
Next we’ll setup the high availability. This is where the second network adapters come into play. First we install the service.
- Open up a command prompt window
- C:\Sun\AppServer\hadb\4.4.3-6\bin\
- Run the command: ma -i ma.cfg to install the service.
- open windows services and verify the HADBManagementAgent service is running.
- Repeat on second server.
Next we need to setup the HADB domain.
- On each server type the command hadbm listdomain, if a domain exists, delete it by using the command: hadbm deletedomain.
- On SERVER1 execute the following command:
- asadmin configure-ha-cluster –user admin –hosts 192.168.1.103,192.168.1.104 –devicesize 256 application_cluster
- It is important here that we use the IP addresses from the NIC’s that are not network load balanced.
Windows Services
Now that everything should be running well, we will register glassfish as a windows service so it starts up automatically. I will user SERVER1 below, make sure you repeat this for SERVER2.
- Stop the node agent if it is running, do this from Start->Program Files->Sun Stop Node Agent.
- Create a file named password.txt in C:\Sun\Appserver
- Add the text below to the file, replacing adminadmin with your password.
- Open a command prompt window and navigate to system32.
- type the command below:
AS_ADMIN_MASTERPASSWORD=adminadmin AS_ADMIN_PASSWORD=adminadmin
Test Application Deployment
To test the server configuration Sun includes the Sample application clusterjsp. It is a simple application that tells you what server instance processed your request, and allows you to create session variables. you can then experiment will shutting down server instances and seeing if the session data persists. To deploy the app we do the following:
- In the glassfish admin console, select Enterprise Applications then click Deploy.
- For location browse to the following file: C:\Sun\AppServer\samples\quickstart\clusterjsp\clusterjsp.ear
- Check the box for availability.
- Add only application_cluster for Targets.
- Click OK.
- Expand Clusters and select application_cluster
- Click on the applications tab, check clusterjsp, and select Load Balancer Enable from the –more actions– drop down.
- Repeat the steps for setting up the Load Balancing. Your new loadbalancer.xml should look something like the following:
- Navigate to http://192.168.1.2/clusterjsp to test the server. Make sure you use the virtual IP to reference the application.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE loadbalancer PUBLIC "-//Sun Microsystems Inc.//DTD Sun Java System Application Server 9.1//EN" "sun-loadbalancer_1_2.dtd">
<loadbalancer>
<cluster name="application_cluster" policy="round-robin">
<instance disable-timeout-in-minutes="30" enabled="true" listeners="http://SERVER1:38080 https://SERVER1:38181" name="app_2" weight="100"/>
<instance disable-timeout-in-minutes="30" enabled="true" listeners="http://SERVER1:38081 https://SERVER1:38182" name="app_1" weight="100"/>
<instance disable-timeout-in-minutes="30" enabled="true" listeners="http://SERVER2:38080 https://SERVER2:38181" name="app_3" weight="100"/>
<instance disable-timeout-in-minutes="30" enabled="true" listeners="http://SERVER2:38081 https://SERVER2:38182" name="app_4" weight="100"/>
<web-module context-root="/clusterjsp" disable-timeout-in-minutes="30" enabled="true"/>
<health-checker interval-in-seconds="30" timeout-in-seconds="10" url="/"/>
</cluster>
<property name="response-timeout-in-seconds" value="60"/>
<property name="reload-poll-interval-in-seconds" value="60"/>
<property name="https-routing" value="true"/>
<property name="require-monitor-data" value="false"/>
<property name="last-exported" value=""/>
<property name="active-healthcheck-enabled" value="false"/>
<property name="number-healthcheck-retries" value="3"/>
<property name="rewrite-location" value="true"/>
</loadbalancer>
<!--
This file was generated on: [Wed Aug 26 00:54:11 GMT-10:00 2009].
Debugging Tips:
By default, instances and web-modules are not enabled. Please enable them manually if you have not done that using asadmin.
-->
SSL (optional)
SSL is very straight forward to setup; it only involves IIS. Microsoft has an excellent tutorial on how to achieve this:
Summary
If you have any problems or questions leave a comment below and I will try to answer.





September 5th, 2009 at 01:33
Very nice documentation. I’ve been writing up programming experiences also at http://coderkyle.blogspot.com
August 22nd, 2010 at 04:59
Thanks for this usefull information.
September 9th, 2010 at 10:08
Great post!