CopyDisable

Monday 15 August 2011

Starting Glassfish domain automatically in Windows

In my previous post (Creating multiple domains in Glassfish 2.1), I discussed how to create additional domains in Glassfish. When we install Glassfish Enterprise Server v2.1.1, it has option to create windows service for the default domain it creates. But when we create additional domains we may need them to start automatically when we start Windows. I will describe two ways to create windows service for a glassfish domain.
I am using Windows XP machine with Glassfish Enterprise Server v2.1.1. My Glassfish server is installed in F:\Glassfish.

The two ways are as follows:

1) The first way is to use the well known sc program. In this example I am creating a service for my domain3. Here I am using the appservService.exe program (it comes with Sun Java System Application Server) with Windows sc program. The name of the service will be GlassfishDomain3 and this service will be displayed as GlassfishDomain3 and it will be started automatically.




2) The second way is to use the utility GlassfishSvc. It is written by Ryan de Laplante and can be downloaded from http://wiki.glassfish.java.net/attach/FaqRunAsWindowsService/GlassfishSvc.jar
Copy the GlassfishSvc.jar to the Glassfish installation folder (in my case it is F:\Glassfish). It is a command line utility and very easy to use. Now I am going to create service for my domain domain2.





The different options of this utility are:
-i Installs a windows service (only for glassfish).
-n Name of the windows service.
-m Name of the glassfish domain for which I am creating service.
-a Glassfish admin user name. Default value is admin.
-p Glassfish admin user’s password. A password.txt file will be created in the Glassfish install directory containing the line AS_ADMIN_PASSWORD=password , and the Windows service will read this file for starting the domain. If no password is entered, the password.txt file will not be created.
-d Specify the directory where Glassfish is installed, as I have copied this tool to glassfish installation folder and running it from that folder, so in my case no need to specify this option as it takes the current directory as default value. If we have to specify the directory path, double quotes need to be added around the path with spaces, and escape back slashes.
I like the second option as it is very easy to use and has some simple options. Also we can use this GlassfishSvc utility to uninstall a glassfish service in a very simple way.
Suppose we are uninstalling the service GlassfishDomain3 for the domain domain3. Use the –u option of GlassfishSvc to uninstall the service.









জয় আই অসম,
প্রণব শর্মা

No comments:

Post a Comment