tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew <Awbal...@smumn.edu>
Subject NT Service in 4.01 (tomcat.exe) installation/documentation
Date Tue, 20 Nov 2001 20:31:44 GMT
1. Difficult to locate documentation of installation of the NT Service. There 
is no documentation that I could find, in the distribution or CVS repository, 
regarding the installation on Tomcat 4.01 as a Service on NT. I recomend 
placing a quick example in the documentation on how to install Tomcat as an NT 
Service.

2. A program is included with the distribution to install Tomcat as an NT 
Service (tomcat.exe). This was found by browsing the bin directory while 
trying to determine the best way to install tomcat 4 as a service. However 
again, there is no documentation other than a concise commandline reference. 
And no reference I could find in the Tomcat Documentation. I would recommend 
at least mentioning the NT Service installation (tomcat.exe) included in the 
binary download.

3. Further investigation (in particular of the CVS repository) led to the 
discovery of the Installer script for NSIS. In this manner, the inclusion of a 
simple NT Services install in the binary release (EXE) was noted. However due 
to the use of JDK1.4Beta3 on the server, the installer failed with the 
inability to find JDK. (This is due to the registry check for the runtime 
environment) My environment does not include a seperate install of the Java 
Runtime environment as such is not neccessary at this time. Adding the option 
to specify where the Java Dll is located may solve this issue.

4. Because of the time consuming process of typing all the information at the 
command line to do an installation of Tomcat as a NT Service I created a 
script to handle the menial tasks (run from %CATALINA_HOME%\bin). The script 
currently has the option to specify the NT Service name (To suppost multiple 
containers, etc.) and the option to specify the security support. In addition 
the script handles finding the Java Dll automatically (can also be specified). 
However all other catalina start options were removed. They could probably be 
easily added by hand to the script. About half of the code used in the script 
was taken directly from 'catalina.bat'.

The following is the full script (might be linewrapped):


@echo off
rem 
---------------------------------------------------------------------------
rem ntservice.cmd - script to install/remove the Tomcat ntservice
rem
rem Environment Variable Prequisites:
rem
rem   CATALINA_BASE (Optional) Base directory for resolving dynamic portions
rem                 of a Catalina installation.  If not present, resolves to
rem                 the same directory that CATALINA_HOME points to.
rem
rem   CATALINA_HOME (Optional) May point at your Catalina "build" directory.
rem                 If not present, the current working directory is assumed.
rem
rem   CATALINA_OPTS (Optional) Java runtime options used when the "start",
rem                 "stop", or "run" command is executed.
rem
rem   JAVA_HOME     Must point at your Java Development Kit installation.
rem
rem   JAVADLL       (Optional) May point at your Java DLL. This can be used
rem                 to specify the DLL used to run Tomcat.
rem
rem   JSSE_HOME     (Optional) May point at your Java Secure Sockets Extension
rem                 (JSSE) installation, whose JAR files will be added to the
rem                 system class path used to start Tomcat.
rem
rem 
---------------------------------------------------------------------------


rem ----- Save Environment Variables That May Change 
--------------------------

set _CATALINA_BASE=%CATALINA_BASE%
set _CATALINA_HOME=%CATALINA_HOME%
set _CLASSPATH=%CLASSPATH%
set _CP=%CP%


rem ----- Verify and Set Required Environment Variables 
-----------------------

if not "%JAVA_HOME%" == "" goto gotJava
echo You must set JAVA_HOME to point at your Java Development Kit installation
goto cleanup
:gotJava

if not "%CATALINA_HOME%" == "" goto gotHome
set CATALINA_HOME=.
if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
set CATALINA_HOME=..
:gotHome
if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
echo Cannot find catalina.bat in %CATALINA_HOME%\bin
echo Please check your CATALINA_HOME setting
goto cleanup
:okHome

if not "%CATALINA_BASE%" == "" goto gotBase
set CATALINA_BASE=%CATALINA_HOME%
:gotBase


rem ----- Prepare Appropriate Java Execution Commands 
-------------------------

if not "%OS%" == "Windows_NT" goto noNT
if not exist "%JAVADLL%" goto findJVM
set _JAVADLL=%JAVADLL%
goto gotJVM
:findJVM
if not exist "%JAVA_HOME%\jre\bin\server\jvm.dll" goto noJVMyet
set _JAVADLL="%JAVA_HOME%\jre\bin\server\jvm.dll"
goto gotJVM
:noJVMyet
if not exist "%JAVA_HOME%\jre\bin\client\jvm.dll" goto noJVM
set _JAVADLL="%JAVA_HOME%\jre\bin\client\jvm.dll"
goto gotJVM
:noJVM
echo This script could not find the Java DLL please set JAVADLL
echo to point at your Java DLL.
goto cleanup
:nonoNT
echo This script can only be used on NT4 and Win2k.
goto cleanup
:gotJVM

rem ----- Set Up The Runtime Classpath 
----------------------------------------

set CP=%CATALINA_HOME%\bin\bootstrap.jar;%JAVA_HOME%\lib\tools.jar
if "%JSSE_HOME%" == "" goto noJsse
set 
CP=%CP%;%JSSE_HOME%\lib\jcert.jar;%JSSE_HOME%\lib\jnet.jar;%JSSE_HOME%\lib\jss
e.jar
:noJsse
set CLASSPATH=%CP%
echo Using CATALINA_BASE: %CATALINA_BASE%
echo Using CATALINA_HOME: %CATALINA_HOME%
echo Using CLASSPATH:     %CLASSPATH%
echo Using JAVA_HOME:     %JAVA_HOME%
echo Using JAVADLL:       %_JAVADLL%

rem ----- Set up the name of the Server 
---------------------------------------

if "%2" == "-name" goto givenName3
if "%3" == "-name" goto givenName4
set _NAME="Tomcat 4.0.1"
goto execute
:givenName3
set _NAME=%3
goto execute
:givenName4
set _NAME=%4

rem ----- Execute The Requested Command 
---------------------------------------

:execute
if "%1" == "install" goto doInstall
if "%1" == "remove" goto doRemove

:doUsage
echo Usage:  ntservice ( install ^| remove ) [-name service]
echo Commands:
echo   install -   Installs the Tomcat Nt Service
echo   remove  -   Removes the Tomcat Nt Service
goto cleanup

:doInstall
if "%2" == "-security" goto doInstallSecure
if "%4" == "-security" goto doInstallSecure
tomcat -install %_NAME% %_JAVADLL% "-Djava.class.path=%CLASSPATH%" 
"-Dcatalina.base=%CATALINA_BASE%" "-Dcatalina.home=%CATALINA_HOME%" -start 
org.apache.catalina.startup.Bootstrap -params start -stop 
org.apache.catalina.startup.Bootstrap -params stop -out 
"%CATALINA_BASE%\logs\service.out.txt" -err 
"%CATALINA_BASE%\logs\service.err.txt" -current "%CATALINA_BASE%" > 
install.bat
goto cleanup
:doInstallSecure
tomcat -install %_NAME% %_JAVADLL% "-Djava.class.path=%CLASSPATH%" 
"-Djava.security.manager" 
"-Djava.security.policy==%CATALINA_BASE%/conf/catalina.policy" 
"-Dcatalina.base=%CATALINA_BASE%" "-Dcatalina.home=%CATALINA_HOME%" -start 
org.apache.catalina.startup.Bootstrap -params start -stop 
org.apache.catalina.startup.Bootstrap -params stop -out 
"%CATALINA_BASE%\logs\service.out.txt" -err 
"%CATALINA_BASE%\logs\service.err.txt" -current "%CATALINA_BASE%"
goto cleanup

:doRemove
tomcat -uninstall %_NAME%

rem ----- Restore Environment Variables 
---------------------------------------

:cleanup
set CATALINA_BASE=%_CATALINA_BASE%
set _CATALINA_BASE=
set CATALINA_HOME=%_CATALINA_HOME%
set _CATALINA_HOME=
set CLASSPATH=%_CLASSPATH%
set _CLASSPATH=
set CP=%_CP%
set _LIBJARS=
set _JAVADLL=
set _NAME=
:finish

Andrew Ballanger

===============================================
"If silence be good for the wise,
how much better for fools."
 -- The Talmud

"Life without reflection is blind."
 -- Socrates


--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message