Hi there,
I'm trying to install tomcat 5.5.16 as a service on my Windows XP
machine using the service.bat script.  I tried following the
instructions given at
http://tomcat.apache.org/tomcat-5.5-doc/windows-service-howto.html to
specify the user account (the --User parameter, in conjunction with the
--Password parameter) the service should run as.  Though tomcat installs
as a service, I'm unable to get it to start as the specified user; it
always starts as "SYSTEM" user.  I've attached the service.bat (with my
modifications) to this mail.  Any help/pointers will be greatly
appreciated.  Thanks,
 
Rajesh Rajamani
 
@echo off
if "%OS%" == "Windows_NT" setlocal
rem
------------------------------------------------------------------------
---
rem NT Service Install/Uninstall script
rem
rem Options
rem install                Install the service using Tomcat5 as service
name. 
rem                        Service is installed using default settings.
rem remove                 Remove the service from the System.
rem
rem name        (optional) If the second argument is present it is
considered 
rem                        to be new service name

rem
rem $Id: service.bat 304097 2005-09-22 13:34:05Z yoavs $
rem
------------------------------------------------------------------------
--- 

set JRE_HOME=C:/Program Files/Java/jdk1.5.0_06/jre/bin/java.exe/../..
set CATALINA_HOME=C:/Program
Files/Solidcore/S3/S3Analytics-1.0.0/apache-tomcat-5.5.16

rem Guess CATALINA_HOME if not defined
set CURRENT_DIR=%cd% 
if not "%CATALINA_HOME%" == "" goto gotHome
set CATALINA_HOME=%cd%
if exist "%CATALINA_HOME%\bin\tomcat5.exe" goto okHome
rem CD to the upper dir
cd ..
set CATALINA_HOME=%cd% 
:gotHome
if exist "%CATALINA_HOME%\bin\tomcat5.exe" goto okHome
echo The tomcat.exe was not found...
echo The CATALINA_HOME environment variable is not defined correctly.
echo This environment variable is needed to run this program 
goto end
rem Make sure prerequisite environment variables are set
if not "%JAVA_HOME%" == "" goto okHome
echo The JAVA_HOME environment variable is not defined
echo This environment variable is needed to run this program 
goto end 
:okHome
if not "%CATALINA_BASE%" == "" goto gotBase
set CATALINA_BASE=%CATALINA_HOME%
:gotBase
 
set EXECUTABLE=%CATALINA_HOME%\bin\tomcat5.exe

rem Set default Service name 
set SERVICE_NAME=Analytics
set PR_DISPLAYNAME=Solidcore S3

if "%1" == "" goto displayUsage
if "%2" == "" goto setServiceName
set SERVICE_NAME=%2
set PR_DISPLAYNAME=Solidcore S3 %2 
:setServiceName
if %1 == install goto doInstall
if %1 == remove goto doRemove
if %1 == uninstall goto doRemove
echo Unknown parameter "%1"
:displayUsage
echo.
echo Usage: service.bat install/remove [service_name] 
goto end

:doRemove
rem Remove the service
"%EXECUTABLE%" //DS//%SERVICE_NAME%
echo The service '%SERVICE_NAME%' has been removed
goto end

:doInstall
rem Install the service
echo Installing the service '%SERVICE_NAME%' ... 
echo Using CATALINA_HOME:    %CATALINA_HOME%
echo Using CATALINA_BASE:    %CATALINA_BASE%
echo Using JAVA_HOME:        %JAVA_HOME%

rem Use the environment variables as an example
rem Each command line option is prefixed with PR_ 

set PR_DESCRIPTION=Solidcore S3 Analytics - http://www.solidcore.com
<http://www.solidcore.com/> 
set PR_INSTALL=%EXECUTABLE%
set PR_LOGPATH=%CATALINA_BASE%\logs
set PR_CLASSPATH=%CATALINA_HOME%\bin\bootstrap.jar 
rem Set the server jvm from JAVA_HOME
set PR_JVM=%JRE_HOME%\bin\server\jvm.dll
if exist "%PR_JVM%" goto foundJvm
rem Set the client jvm from JAVA_HOME
set PR_JVM=%JRE_HOME%\bin\server\jvm.dll
if exist "%PR_JVM%" goto foundJvm
rem set PR_JVM=auto
echo Could not find proper jvm.dll
goto end
:foundJvm
echo Using JVM:              %PR_JVM%
"%EXECUTABLE%" //IS//%SERVICE_NAME%  --StartMode exe --User raj
--Password mypass --StartClass org.apache.catalina.startup.Bootstrap
--StopClass org.apache.catalina.startup.Bootstrap --StartParams start
--StopParams stop --Startup auto
if not errorlevel 1 goto installed
echo Failed installing '%SERVICE_NAME%' service 
goto end
:installed
rem Clear the environment variables. They are not needed any more.
set PR_DISPLAYNAME=
set PR_DESCRIPTION=
set PR_INSTALL=
set PR_LOGPATH=
set PR_CLASSPATH=
set PR_JVM=
rem Set extra parameters 
"%EXECUTABLE%" //US//%SERVICE_NAME% --JvmOptions
"-Xms512m;-Xmx1024m;-Dcatalina.base=%CATALINA_BASE%;-Dcatalina.home=%CAT
ALINA_HOME%;-Djava.endorsed.dirs=%CATALINA_HOME%\common\endorsed"
--StartMode jvm --StopMode jvm 
rem More extra parameters
set PR_LOGPATH=%CATALINA_BASE%\logs
set PR_STDOUTPUT=auto
set PR_STDERROR=auto
"%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions
"-Djava.io.tmpdir=%CATALINA_BASE%\temp " --JvmMs 128 --JvmMx 256
echo The service '%SERVICE_NAME%' has been installed.

:end
cd %CURRENT_DIR%


Reply via email to