CopyDisable

Monday 16 April 2012

Creating Glassfish Cluster Instance Service

In one of my previous blog Glassfish 3.1 Cluster in Windows environment I wrote about creating Glassfish cluster in Windows environment. After cluster was created, my requirement was to run the cluster instances as daemon processes and under some user with low privilege in the server. If we run glassfish cluster instance normally from our login, once we logoff from the system, the process also terminates. Glassfish provide create-service sub-command to create windows service for a glassfish domain or cluster instance.

Step 1: Create service for the Domain Admin Server (DAS)
cmd:\> asadmin create-service domain1
1 

Step 2: Create services for all the instances of the cluster
cmd:\> asadmin create-service <instance-name>
2

Now all my services are created and started, so logoff from the servers and check whether my application is running fine in the cluster. Ooooppppppppppssssss…………… page can be displayed, my application is not running. Login to the server and check, and if I see the windows task manager, I could not see the processes for my cluster instances. That means when I logoff from the system, the cluster instance services also terminated.
Previously in Glassfish V2, we have to add one JVM option –Xrs (http://docs.oracle.com/javase/1.3/docs/tooldocs/solaris/java.html#Xrs) to resolve this problem. But this time after adding –Xrs option to all the glassfish instances did not work for me. Then this blog came as a rescuer for me
https://blogs.oracle.com/foo/entry/how_to_make_v3_platform .  This blog nicely explains what we have to do in Glassfish V3 for making a Glassfish service to survive user logoff, please go through it. From the blog I found that I have to add –Xrs option to asadmin also.

Steps1: Add –Xrs option to all glassfish cluster instances.
This can be done directly from Glassfish admin web-console, it is simple to add the option from admin console.
Untitled-2

Click on Add JVM Option button
Untitled-3

Add –Xrs and click on Save button.
Untitled-4

Steps2: Add –Xrs option to asadmin.bat file
Open the asadmin.bat file and add the –Xrs option

Untitled-5

That’s all, now safely logoff from the system.