I had a requirement to install two separate instances of GlassFish v2 on the same box. I initially looked at using separate domains but for infrastructure reasons, I needed to separate installations (long story).
This is my desired configuration:
- Service 1: GlassFish for CMS server
- Service 2: GlassFish for Portal server
I have two installations of GlassFish on my box. They are installed in the following directories:
- c:/Sun/Glassfishv2_cmsinstall
- c:/Sun/Glassfishv2_portalinstall
GlassFish has out of the box support for setting up a Windows service. However, if I installed a second version on my machine, the Windows service will use the same name and entry. Effectively overwriting the first service. I needed a way to create the Window’s service and give them a custom name in the services list.
I made use of Ryan de Leplante’s utility for creating the services. It was really easy.
These are the steps for setting up the two services.
- Download the utility
- Issue the following commands
java -jar glassfishsvc.jar -i -n "GlassFish for CMS" -d "C:/Sun/Glassfishv2_cmsinstall" java -jar glassfishsvc.jar -i -n "GlassFish for Portal Server" -d "C:/Sun/Glassfishv2_portalinstall"
Verify
Verify the services in the Windows control panel. Seee the screenshot below. Make note of the custom names that easily identifies each services.
User Logout
As noted in Ryan de Leplante’s post, the GlassFish service will shut down if a user logs out. In my case, I need for the Windows service to continue running even on log out. In order to keep the service up, you need to edit two files.
Edit: <GF_HOME>\domains\domain1\config\domain.xml
In the JVM options section, add the following:
<jvm-options>-Xrs</jvm-options>
Edit: <GF_HOME>\lib\processLauncher.xml
In the <process> section, add the following:
<sysproperty key="-Xrs"/>
Wrap Up
As you can see, this solved my problem. I now have two separate installations of GlassFish. I can start and stop each service independently. Also make note of the custom names that easily identifies each services.
Hope this helps 🙂