Working with the Jakarta NT Service
By Gal Shachor <shachor@il.ibm.com
>
Modified by Dave Oxley <dave@junglemoss.com
>
The Jakarta NT service is an executable that wraps the Tomcat servlet container
and executes it in the background as an NT service. To install it you will
need to:
- Get a hold on the NT executable (jk_nt_service.exe)
- Download the executable from the win32/i386 directory found
where you downloaded the
Tomcat binary distribution.
For those using Netscape as your browser, try downloading a zip
version of the file, if available. There can be problems using Netscape
to download DLL files.
- Customize a properties file that provides the service with Tomcat
information (wrapper.properties).
- Locate the wrapper.properties template file in your Tomcat conf/jk
directory.
- Update the wrapper.tomcat_home property to point at your tomcat
home.
- Update the wrapper.java_home property to point at your Java
home.
- Install jk_nt_service by running it with the -i flag.
- Execute jk_nt_service -I <name of service> <optional
params> <path to updated wrapper properties>
- <name of service> should be a single word (without and
spaces) such as Jakarta
- <optional params> are any of the following:
- -U <user name> - to set the user the service runs as. Make
sure the user has 'Logon as a service right'. The <user name> must
be in the format DomainName\UserName (e.g. Dev\Administrator for Administrator
in the Dev domain or .\Administrator for the local Administrator)
- -P <user password> - Valid password for the user.
- -A - Sets the service to startup automatically.
- -D <service dependancy> - This sets the service that must
be started prior to this one. -D <service dependancy> can be specified
multiple times. <service dependancy> must be the 'Service Name' not
the 'Display Name'.
- <path to updated wrapper properties> should point to your
wrapper.properties file (and the service will check it's existence.)
- For example, valid command lines can be:
- jk_nt_service -I Jakarta wrapper.properties
- jk_nt_service -I Jakarta -U .\Administrator -P password -A -D MSSQLSERVER
wrapper.properties
- Start tomcat as a service.
- From the command line, execute jk_nt_service -S <name of service>
<optional param> where <optional param> is:
- -M <machine name> - Remote machine to start the service on.
(e.g. jk_nt_service -S Jakarta -M DevBox)
- From the command line, execute net start <name of service>
(e.g. net start Jakarta)
- From the NT services applet, highlight your service and press
start.
Note: If the log file location in your wrapper.properties file points
to the logs directory, and the logs directory doesn't
yet exist, manually create it before starting the service.
- Stop Tomcat as a service.
- From the command line, execute jk_nt_service -T <name of service>
<optional param> where <optional param> is:
- -M <machine name> - Remote machine to stop the service on.
(e.g. jk_nt_service -T Jakarta -M DevBox)
- From the command line, execute net stop <name of service>
(e.g. net stop Jakarta)
- From the NT services applet, highlight your service and press
stop.
Special note: The Tomcat service is using AJPV12 to perform clean
shutdown and you should make sure that an AJPV12 connector is defined in
your server.xml. In the absence of a configured AJPV12 port the Tomcat service
will kill Tomcat abruptly (that is murder it) without giving it a chance
to clean up.
Special note2: Acording to
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=2337
, you may have problems with long filenames. You should use the 8.3 format.
Thanks to Anthony Dodd for finding this workaround.
Notice for JDK 1.3 users: There is a
known problem
in JDK 1.3 that affects Java applications being run as Windows NT services.
The bug causes the service to terminate when the currently logged in user
logs out. The simplest way to work around this problem is to use JDK 1.2.
If your application requires JDK 1.3 features then you may want to look
into javaserv
or JavaService
. Users have reported success with both of these packages but there may
be others that work as well.
To remove the installed service, execute jk_nt_service -R <name of service>
Advance Setup
- Modify the Tomcat NT service properties. By default the service
will run in manual mode and under the local system user account. To
modify this, open the NT services applet, highlight your service and
press startup. A popup window is opened and you will be able to customize
the service to your satisfaction.
- Modify the classpath. The classpath is determined by the wrapper.class_path
properties, to modify it just add/remove/modify wrapper.class_path
lines. The complete classpath is calculated by concatenating all the
wrapper.class_path lines and putting ";" between them.
- Execute several Tomcat instances. Say that you want one Tomcat
to run for "production" and one for development, you can do that. All
you will need to do is to install the Tomcat service twice and under
two different names (and with different wrapper.properties file and
server.xml files).
- Make sure that the AJPV12 and HTTP connectors are modified in
each server.xml file to prevent a clash.
- Make sure to update the wrapper.shutdown_port property in wrapper.properties
to point to the correct AJPV12 shutdown ports (default is 8007).
- Modify the command line used to start Tomcat. The Tomcat service
is taking all it's command line configuration from wrapper.properties!
To customize the command line, edit the property wrapper.cmd_line and
make sure that it makes a legal Java command line.
Feedback
Please send feedback, bug report or any additional information to
<tomcat-user@jakarta.apache.org
>