Creating a Windows service for Glassfish V2 :
With GlassfishSvc.jar
Ryan de Laplante has contributed a simple command line tool that makes the creation of a Windows service effortless. Download GlassfishSvc.jar (source) and copy it into your Glassfish installation path (such as C:\Program Files\Sun\GlassfishV2\), then run the following command from the command line:
--------------------------------------------------------------------------------
C:\Program Files\Sun\GlassfishV2>java -jar GlassfishSvc.jar -i
glassfishsvc v1.0 (Aug 19 2007)
Service name : GlassfishAppServer
Glassfish installation path : C:\Program Files\Sun\GlassfishV2
Glassfish domain : domain1
Glassfish admin username : admin
Installing service... Done.
--------------------------------------------------------------------------------
The -i argument will install the service with default options. A complete listing of the command line arguments follows:
--------------------------------------------------------------------------------
glassfishsvc v1.0 (Aug 19 2007)
DESCRIPTION:
Installs and uninstalls a Windows service for Glassfish
USAGE:
java -jar glassfishsvc.jar [-i | -u] [OPTIONS]
-i Installs a Windows service for Glassfish.
-u Uninstalls a Windows service for Glassfish.
-n name Name for the Windows service. Use double quotes around names
that contain spaces. Defaults to GlassfishAppServer.
-d path Directory where Glassfish is installed. Use double
quotes around paths with spaces, and escape back slashes.
Defaults to current directory.
-m domain Name of the Glassfish domain to start and stop. Defaults to
domain1.
-a user Glassfish admin user name. Defaults to admin.
-p pwd Glassfish admin password. A password.txt file will be created
in the Glassfish install directory containing the password in
plain text, and the Windows service will be configured to read
from it. This is usually not necessary. If no password is passed
in, the password.txt file will not be created.
EXAMPLES:
java -jar glassfishsvc.jar -i
java -jar glassfishsvc.jar -i -p adminadmin
java -jar glassfishsvc.jar -i -n MyServiceName -d "C:\\Program Files\\Sun\\Glassfish" -m myDomain -a admin5 -p secretpwd
java -jar glassfishsvc.jar -u
java -jar glassfishsvc.jar -u -n MyServiceName
AUTHOR:
Ryan de Laplante
--------------------------------------------------------------------------------
Cluster Profile
If you installed the Glassfish cluster profile then Glassfish will ask for the admin password as the service starts. To get around this use the -p option when installing the service. A password.txt file will be created in Glassfish's root directory containing the password in plain text. The Windows service will be configured to use this file so that it can start unattended. You should make sure to configure appropriate NTFS security on this file after it is created so that unauthorized users do not have read or write access to it.Windows User Log-out
By default the JVM catches signals from Windows that indicate the OS is shutting down, or a user is logging out, and shuts itself down cleanly. This means that the Glassfish service will be shut down any time a user logs out of Windows. This defeats the purpose of having a Windows service so we need to turn off this JVM feature by using the -Xrs JVM option.
Open the
-Xrs
Save and close domain.xml. If the Glassfish service is already running, restart it for the change to take effect.
Note: There have been reports that adding the -Xrs jvm-option to domain.xml does not solve this problem on some Windows 2003 Server installations. The reported solution is to add the jvm option to
...
...
0 comments:
Post a Comment