You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by mailinglist <ma...@stopware.com> on 2009/04/08 01:52:37 UTC

Services not working under Program Files folder

Hi,

I am trying to create a tomcat service with the service.bat.  The
service.bat looks for my environment variable to create the service.  If
my directory name has a space in it (e.g. Program files) it will create
the service but it will not start.  It keeps saying that the service has
nothing to do.  But if i change my directory to Programfiles, then it
would be fine.  I cannot figure out why, it will not work.  I even check
the services properties to see the path "c:\Program Files\......", and
this seems fine to me.  Does anyone know what I am missing?  I provided
the service.bat below also:


@echo off
if "%OS%" == "Windows_NT" setlocal
set CURRENT_DIR=%cd%
echo Current Directory = %cd%

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
---------------------------------------------------------------------------

rem
---------------------------------------------------------------------------
rem PassagePoint settings
rem
---------------------------------------------------------------------------
if exist "%PP_HOME%\client.bat" goto okPPHome
rem Try to set PP_Home manually based on the current directory
(...\tomcat\bin)
cd ..\..
set PP_Home=%cd%
cd %CURRENT_DIR%

:okPPHome
echo PP_Home = %PP_HOME%
set JAVA_HOME=%PP_HOME%\Java
set PATH=%JAVA_HOME%\bin;%PATH%

rem Guess PPService_HOME if not defined
rem Checking service home ...
if not "%PPService_HOME%" == "" goto gotHome
rem CD to the upper dir
cd ..
set PPService_HOME=%cd%
cd %CURRENT_DIR%

:gotHome
rem Checking if Tomcat5.exe exists ...
if exist "%PPService_HOME%\bin\tomcat5.exe" goto okHome
echo The tomcat.exe was not found...
echo The PPService_HOME environment variable is not defined correctly.
echo This environment variable is needed to run this program
goto end

:okHome
rem Make sure prerequisite environment variables are set
rem Checking Java home ...
if not "%JAVA_HOME%" == "" goto okJava
echo The JAVA_HOME environment variable is not defined
echo This environment variable is needed to run this program
goto end

:okJava
if not "%PPService_BASE%" == "" goto gotBase
rem Setting service base to service home ...
set PPService_BASE=%PPService_HOME%

:gotBase
rem Setting service executable to tomcat5 ...
set EXECUTABLE=%PPService_HOME%\bin\tomcat5.exe

::------------------------------------------------------
:: Start configuring Tomcat service - environment ready
::------------------------------------------------------
rem Set default Service name
set SERVICE_NAME=PPServer
set PR_DISPLAYNAME=PassagePoint Server

if "%1" == "" goto displayUsage
if "%2" == "" goto setServiceName
set SERVICE_NAME=%2
set PR_DISPLAYNAME=Apache Tomcat %2

:setServiceName
if %1 == install goto doInstall
if %1 == remove goto doRemove
if %1 == uninstall goto doRemove
echo Unknown parameter specified: "%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 Use the environment variables as an example
rem Each command line option is prefixed with PR_
set PR_DESCRIPTION=PassagePoint Server (Apache Tomcat5)
set PR_INSTALL=%EXECUTABLE%
set PR_LOGPATH=%PPService_BASE%\logs
set PR_CLASSPATH=%PPService_HOME%\bin\bootstrap.jar

rem Set the server jvm from JAVA_HOME
set PR_JVM=%JAVA_HOME%\bin\server\jvm.dll
if exist "%PR_JVM%" goto foundJvm
rem Set the client jvm from JAVA_HOME
set PR_JVM=%JAVA_HOME%\bin\client\jvm.dll
if exist "%PR_JVM%" goto foundJvm
set PR_JVM=auto

:foundJvm
rem Install the service
echo Installing the service '%SERVICE_NAME%' ...
echo Using PPService_HOME:   %PPService_HOME%
echo Using PPService_BASE:   %PPService_BASE%
echo Using JAVA_HOME:        %JAVA_HOME%
echo Using JVM:              %PR_JVM%

"%EXECUTABLE%" //IS//%SERVICE_NAME% --StartClass
org.apache.catalina.startup.Bootstrap --StopClass
org.apache.catalina.startup.Bootstrap --StartParams start --StopParams
stop
if not errorlevel 1 goto installed
echo Failed installing '%SERVICE_NAME%' service
goto end

:installed
rem Clear the environment variables which 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
"-Dcatalina.base=%PPService_BASE%;-Dcatalina.home=%PPService_HOME%;-Djava.endorsed.dirs=%PPService_HOME%\common\endorsed"
--StartMode jvm --StopMode jvm

rem More extra parameters
set PR_LOGPATH=%PPService_BASE%\logs
set PR_STDOUTPUT=auto
set PR_STDERROR=auto
"%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions
"-Djava.io.tmpdir=%PPService_BASE%\temp" --JvmMs 128 --JvmMx 256
"%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions
"\"-Djava.library.path=%PPService_HOME%\bin;%PPService_HOME%\..\config\dll\""
echo The service '%SERVICE_NAME%' has been installed.

rem startup PassagePoint Server service
net start "PPServer"

:end
cd %CURRENT_DIR%




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Services not working under Program Files folder

Posted by Len Popp <le...@gmail.com>.
I have used the service.bat in various versions of Tomcat with no such error.

The script you posted is different from the service.bats in Tomcat
5.0, 5.5 and 6.0 that I have lying around. Where did you get your
service.bat from?
-- 
Len



On Tue, Apr 7, 2009 at 19:52, mailinglist <ma...@stopware.com> wrote:
> Hi,
>
> I am trying to create a tomcat service with the service.bat.  The
> service.bat looks for my environment variable to create the service.  If
> my directory name has a space in it (e.g. Program files) it will create
> the service but it will not start.  It keeps saying that the service has
> nothing to do.  But if i change my directory to Programfiles, then it
> would be fine.  I cannot figure out why, it will not work.  I even check
> the services properties to see the path "c:\Program Files\......", and
> this seems fine to me.  Does anyone know what I am missing?  I provided
> the service.bat below also:
>
>
> @echo off
> if "%OS%" == "Windows_NT" setlocal
> set CURRENT_DIR=%cd%
> echo Current Directory = %cd%
>
> 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
> ---------------------------------------------------------------------------
>
> rem
> ---------------------------------------------------------------------------
> rem PassagePoint settings
> rem
> ---------------------------------------------------------------------------
> if exist "%PP_HOME%\client.bat" goto okPPHome
> rem Try to set PP_Home manually based on the current directory
> (...\tomcat\bin)
> cd ..\..
> set PP_Home=%cd%
> cd %CURRENT_DIR%
>
> :okPPHome
> echo PP_Home = %PP_HOME%
> set JAVA_HOME=%PP_HOME%\Java
> set PATH=%JAVA_HOME%\bin;%PATH%
>
> rem Guess PPService_HOME if not defined
> rem Checking service home ...
> if not "%PPService_HOME%" == "" goto gotHome
> rem CD to the upper dir
> cd ..
> set PPService_HOME=%cd%
> cd %CURRENT_DIR%
>
> :gotHome
> rem Checking if Tomcat5.exe exists ...
> if exist "%PPService_HOME%\bin\tomcat5.exe" goto okHome
> echo The tomcat.exe was not found...
> echo The PPService_HOME environment variable is not defined correctly.
> echo This environment variable is needed to run this program
> goto end
>
> :okHome
> rem Make sure prerequisite environment variables are set
> rem Checking Java home ...
> if not "%JAVA_HOME%" == "" goto okJava
> echo The JAVA_HOME environment variable is not defined
> echo This environment variable is needed to run this program
> goto end
>
> :okJava
> if not "%PPService_BASE%" == "" goto gotBase
> rem Setting service base to service home ...
> set PPService_BASE=%PPService_HOME%
>
> :gotBase
> rem Setting service executable to tomcat5 ...
> set EXECUTABLE=%PPService_HOME%\bin\tomcat5.exe
>
> ::------------------------------------------------------
> :: Start configuring Tomcat service - environment ready
> ::------------------------------------------------------
> rem Set default Service name
> set SERVICE_NAME=PPServer
> set PR_DISPLAYNAME=PassagePoint Server
>
> if "%1" == "" goto displayUsage
> if "%2" == "" goto setServiceName
> set SERVICE_NAME=%2
> set PR_DISPLAYNAME=Apache Tomcat %2
>
> :setServiceName
> if %1 == install goto doInstall
> if %1 == remove goto doRemove
> if %1 == uninstall goto doRemove
> echo Unknown parameter specified: "%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 Use the environment variables as an example
> rem Each command line option is prefixed with PR_
> set PR_DESCRIPTION=PassagePoint Server (Apache Tomcat5)
> set PR_INSTALL=%EXECUTABLE%
> set PR_LOGPATH=%PPService_BASE%\logs
> set PR_CLASSPATH=%PPService_HOME%\bin\bootstrap.jar
>
> rem Set the server jvm from JAVA_HOME
> set PR_JVM=%JAVA_HOME%\bin\server\jvm.dll
> if exist "%PR_JVM%" goto foundJvm
> rem Set the client jvm from JAVA_HOME
> set PR_JVM=%JAVA_HOME%\bin\client\jvm.dll
> if exist "%PR_JVM%" goto foundJvm
> set PR_JVM=auto
>
> :foundJvm
> rem Install the service
> echo Installing the service '%SERVICE_NAME%' ...
> echo Using PPService_HOME:   %PPService_HOME%
> echo Using PPService_BASE:   %PPService_BASE%
> echo Using JAVA_HOME:        %JAVA_HOME%
> echo Using JVM:              %PR_JVM%
>
> "%EXECUTABLE%" //IS//%SERVICE_NAME% --StartClass
> org.apache.catalina.startup.Bootstrap --StopClass
> org.apache.catalina.startup.Bootstrap --StartParams start --StopParams
> stop
> if not errorlevel 1 goto installed
> echo Failed installing '%SERVICE_NAME%' service
> goto end
>
> :installed
> rem Clear the environment variables which 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
> "-Dcatalina.base=%PPService_BASE%;-Dcatalina.home=%PPService_HOME%;-Djava.endorsed.dirs=%PPService_HOME%\common\endorsed"
> --StartMode jvm --StopMode jvm
>
> rem More extra parameters
> set PR_LOGPATH=%PPService_BASE%\logs
> set PR_STDOUTPUT=auto
> set PR_STDERROR=auto
> "%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions
> "-Djava.io.tmpdir=%PPService_BASE%\temp" --JvmMs 128 --JvmMx 256
> "%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions
> "\"-Djava.library.path=%PPService_HOME%\bin;%PPService_HOME%\..\config\dll\""
> echo The service '%SERVICE_NAME%' has been installed.
>
> rem startup PassagePoint Server service
> net start "PPServer"
>
> :end
> cd %CURRENT_DIR%
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org