1@echo off 2rem Licensed to the Apache Software Foundation (ASF) under one or more 3rem contributor license agreements. See the NOTICE file distributed with 4rem this work for additional information regarding copyright ownership. 5rem The ASF licenses this file to You under the Apache License, Version 2.0 6rem (the "License"); you may not use this file except in compliance with 7rem the License. You may obtain a copy of the License at 8rem 9rem http://www.apache.org/licenses/LICENSE-2.0 10rem 11rem Unless required by applicable law or agreed to in writing, software 12rem distributed under the License is distributed on an "AS IS" BASIS, 13rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14rem See the License for the specific language governing permissions and 15rem limitations under the License. 16 17rem --------------------------------------------------------------------------- 18rem Start/Stop Script for the CATALINA Server 19rem 20rem For supported commands call "catalina.bat help" or see the usage section 21rem towards the end of this file. 22rem 23rem Environment Variable Prerequisites 24rem 25rem Do not set the variables in this script. Instead put them into a script 26rem setenv.bat in CATALINA_BASE/bin to keep your customizations separate. 27rem 28rem WHEN RUNNING TOMCAT AS A WINDOWS SERVICE: 29rem Note that the environment variables that affect the behavior of this 30rem script will have no effect at all on Windows Services. As such, any 31rem local customizations made in a CATALINA_BASE/bin/setenv.bat script 32rem will also have no effect on Tomcat when launched as a Windows Service. 33rem The configuration that controls Windows Services is stored in the Windows 34rem Registry, and is most conveniently maintained using the "tomcat9w.exe" 35rem maintenance utility. 36rem 37rem CATALINA_HOME May point at your Catalina "build" directory. 38rem 39rem CATALINA_BASE (Optional) Base directory for resolving dynamic portions 40rem of a Catalina installation. If not present, resolves to 41rem the same directory that CATALINA_HOME points to. 42rem 43rem CATALINA_OPTS (Optional) Java runtime options used when the "start", 44rem "run" or "debug" command is executed. 45rem Include here and not in JAVA_OPTS all options, that should 46rem only be used by Tomcat itself, not by the stop process, 47rem the version command etc. 48rem Examples are heap size, GC logging, JMX ports etc. 49rem 50rem CATALINA_TMPDIR (Optional) Directory path location of temporary directory 51rem the JVM should use (java.io.tmpdir). Defaults to 52rem %CATALINA_BASE%\temp. 53rem 54rem JAVA_HOME Must point at your Java Development Kit installation. 55rem Required to run the with the "debug" argument. 56rem 57rem JRE_HOME Must point at your Java Runtime installation. 58rem Defaults to JAVA_HOME if empty. If JRE_HOME and JAVA_HOME 59rem are both set, JRE_HOME is used. 60rem 61rem JAVA_OPTS (Optional) Java runtime options used when any command 62rem is executed. 63rem Include here and not in CATALINA_OPTS all options, that 64rem should be used by Tomcat and also by the stop process, 65rem the version command etc. 66rem Most options should go into CATALINA_OPTS. 67rem 68rem JAVA_ENDORSED_DIRS (Optional) Lists of of semi-colon separated directories 69rem containing some jars in order to allow replacement of APIs 70rem created outside of the JCP (i.e. DOM and SAX from W3C). 71rem It can also be used to update the XML parser implementation. 72rem This is only supported for Java <= 8. 73rem Defaults to $CATALINA_HOME/endorsed. 74rem 75rem JPDA_TRANSPORT (Optional) JPDA transport used when the "jpda start" 76rem command is executed. The default is "dt_socket". 77rem 78rem JPDA_ADDRESS (Optional) Java runtime options used when the "jpda start" 79rem command is executed. The default is localhost:8000. 80rem 81rem JPDA_SUSPEND (Optional) Java runtime options used when the "jpda start" 82rem command is executed. Specifies whether JVM should suspend 83rem execution immediately after startup. Default is "n". 84rem 85rem JPDA_OPTS (Optional) Java runtime options used when the "jpda start" 86rem command is executed. If used, JPDA_TRANSPORT, JPDA_ADDRESS, 87rem and JPDA_SUSPEND are ignored. Thus, all required jpda 88rem options MUST be specified. The default is: 89rem 90rem -agentlib:jdwp=transport=%JPDA_TRANSPORT%, 91rem address=%JPDA_ADDRESS%,server=y,suspend=%JPDA_SUSPEND% 92rem 93rem JSSE_OPTS (Optional) Java runtime options used to control the TLS 94rem implementation when JSSE is used. Default is: 95rem "-Djdk.tls.ephemeralDHKeySize=2048" 96rem 97rem CATALINA_LOGGING_CONFIG (Optional) Override Tomcat's logging config file 98rem Example (all one line) 99rem set CATALINA_LOGGING_CONFIG="-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties" 100rem 101rem LOGGING_CONFIG Deprecated 102rem Use CATALINA_LOGGING_CONFIG 103rem This is only used if CATALINA_LOGGING_CONFIG is not set 104rem and LOGGING_CONFIG starts with "-D..." 105rem 106rem LOGGING_MANAGER (Optional) Override Tomcat's logging manager 107rem Example (all one line) 108rem set LOGGING_MANAGER="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager" 109rem 110rem TITLE (Optional) Specify the title of Tomcat window. The default 111rem TITLE is Tomcat if it's not specified. 112rem Example (all one line) 113rem set TITLE=Tomcat.Cluster#1.Server#1 [%DATE% %TIME%] 114rem --------------------------------------------------------------------------- 115 116setlocal 117 118rem Suppress Terminate batch job on CTRL+C 119if not ""%1"" == ""run"" goto mainEntry 120if "%TEMP%" == "" goto mainEntry 121if exist "%TEMP%\%~nx0.run" goto mainEntry 122echo Y>"%TEMP%\%~nx0.run" 123if not exist "%TEMP%\%~nx0.run" goto mainEntry 124echo Y>"%TEMP%\%~nx0.Y" 125call "%~f0" %* <"%TEMP%\%~nx0.Y" 126rem Use provided errorlevel 127set RETVAL=%ERRORLEVEL% 128del /Q "%TEMP%\%~nx0.Y" >NUL 2>&1 129exit /B %RETVAL% 130:mainEntry 131del /Q "%TEMP%\%~nx0.run" >NUL 2>&1 132 133rem Guess CATALINA_HOME if not defined 134set "CURRENT_DIR=%cd%" 135if not "%CATALINA_HOME%" == "" goto gotHome 136set "CATALINA_HOME=%CURRENT_DIR%" 137if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome 138cd .. 139set "CATALINA_HOME=%cd%" 140cd "%CURRENT_DIR%" 141:gotHome 142 143if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome 144echo The CATALINA_HOME environment variable is not defined correctly 145echo This environment variable is needed to run this program 146goto end 147:okHome 148 149rem Copy CATALINA_BASE from CATALINA_HOME if not defined 150if not "%CATALINA_BASE%" == "" goto gotBase 151set "CATALINA_BASE=%CATALINA_HOME%" 152:gotBase 153 154rem Ensure that neither CATALINA_HOME nor CATALINA_BASE contains a semi-colon 155rem as this is used as the separator in the classpath and Java provides no 156rem mechanism for escaping if the same character appears in the path. Check this 157rem by replacing all occurrences of ';' with '' and checking that neither 158rem CATALINA_HOME nor CATALINA_BASE have changed 159if "%CATALINA_HOME%" == "%CATALINA_HOME:;=%" goto homeNoSemicolon 160echo Using CATALINA_HOME: "%CATALINA_HOME%" 161echo Unable to start as CATALINA_HOME contains a semicolon (;) character 162goto end 163:homeNoSemicolon 164 165if "%CATALINA_BASE%" == "%CATALINA_BASE:;=%" goto baseNoSemicolon 166echo Using CATALINA_BASE: "%CATALINA_BASE%" 167echo Unable to start as CATALINA_BASE contains a semicolon (;) character 168goto end 169:baseNoSemicolon 170 171rem Ensure that any user defined CLASSPATH variables are not used on startup, 172rem but allow them to be specified in setenv.bat, in rare case when it is needed. 173set CLASSPATH= 174 175rem Get standard environment variables 176if not exist "%CATALINA_BASE%\bin\setenv.bat" goto checkSetenvHome 177call "%CATALINA_BASE%\bin\setenv.bat" 178goto setenvDone 179:checkSetenvHome 180if exist "%CATALINA_HOME%\bin\setenv.bat" call "%CATALINA_HOME%\bin\setenv.bat" 181:setenvDone 182 183rem Get standard Java environment variables 184if exist "%CATALINA_HOME%\bin\setclasspath.bat" goto okSetclasspath 185echo Cannot find "%CATALINA_HOME%\bin\setclasspath.bat" 186echo This file is needed to run this program 187goto end 188:okSetclasspath 189call "%CATALINA_HOME%\bin\setclasspath.bat" %1 190if errorlevel 1 goto end 191 192rem Add on extra jar file to CLASSPATH 193rem Note that there are no quotes as we do not want to introduce random 194rem quotes into the CLASSPATH 195if "%CLASSPATH%" == "" goto emptyClasspath 196set "CLASSPATH=%CLASSPATH%;" 197:emptyClasspath 198set "CLASSPATH=%CLASSPATH%%CATALINA_HOME%\bin\bootstrap.jar" 199 200if not "%CATALINA_TMPDIR%" == "" goto gotTmpdir 201set "CATALINA_TMPDIR=%CATALINA_BASE%\temp" 202:gotTmpdir 203 204rem Add tomcat-juli.jar to classpath 205rem tomcat-juli.jar can be over-ridden per instance 206if not exist "%CATALINA_BASE%\bin\tomcat-juli.jar" goto juliClasspathHome 207set "CLASSPATH=%CLASSPATH%;%CATALINA_BASE%\bin\tomcat-juli.jar" 208goto juliClasspathDone 209:juliClasspathHome 210set "CLASSPATH=%CLASSPATH%;%CATALINA_HOME%\bin\tomcat-juli.jar" 211:juliClasspathDone 212 213if not "%JSSE_OPTS%" == "" goto gotJsseOpts 214set "JSSE_OPTS=-Djdk.tls.ephemeralDHKeySize=2048" 215:gotJsseOpts 216set "JAVA_OPTS=%JAVA_OPTS% %JSSE_OPTS%" 217 218rem Register custom URL handlers 219rem Do this here so custom URL handles (specifically 'war:...') can be used in the security policy 220set "JAVA_OPTS=%JAVA_OPTS% -Djava.protocol.handler.pkgs=org.apache.catalina.webresources" 221 222rem Check for the deprecated LOGGING_CONFIG 223rem Only use it if CATALINA_LOGGING_CONFIG is not set and LOGGING_CONFIG starts with "-D..." 224if not "%LOGGING_CONFIG:~0,2%"=="-D" goto noLoggingDeprecation 225if not "%CATALINA_LOGGING_CONFIG%" == "" goto noLoggingDeprecation 226set "CATALINA_LOGGING_CONFIG=%LOGGING_CONFIG%" 227:noLoggingDeprecation 228 229if not "%CATALINA_LOGGING_CONFIG%" == "" goto noJuliConfig 230set CATALINA_LOGGING_CONFIG=-Dnop 231if not exist "%CATALINA_BASE%\conf\logging.properties" goto noJuliConfig 232set CATALINA_LOGGING_CONFIG=-Djava.util.logging.config.file="%CATALINA_BASE%\conf\logging.properties" 233:noJuliConfig 234 235if not "%LOGGING_MANAGER%" == "" goto noJuliManager 236set LOGGING_MANAGER=-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager 237:noJuliManager 238 239rem Configure JAVA 9 specific start-up parameters 240set "JDK_JAVA_OPTIONS=%JDK_JAVA_OPTIONS% --add-opens=java.base/java.lang=ALL-UNNAMED" 241set "JDK_JAVA_OPTIONS=%JDK_JAVA_OPTIONS% --add-opens=java.base/java.io=ALL-UNNAMED" 242set "JDK_JAVA_OPTIONS=%JDK_JAVA_OPTIONS% --add-opens=java.base/java.util=ALL-UNNAMED" 243set "JDK_JAVA_OPTIONS=%JDK_JAVA_OPTIONS% --add-opens=java.base/java.util.concurrent=ALL-UNNAMED" 244set "JDK_JAVA_OPTIONS=%JDK_JAVA_OPTIONS% --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED" 245 246rem Java 9 no longer supports the java.endorsed.dirs 247rem system property. Only try to use it if 248rem JAVA_ENDORSED_DIRS was explicitly set 249rem or CATALINA_HOME/endorsed exists. 250set ENDORSED_PROP=ignore.endorsed.dirs 251if "%JAVA_ENDORSED_DIRS%" == "" goto noEndorsedVar 252set ENDORSED_PROP=java.endorsed.dirs 253goto doneEndorsed 254:noEndorsedVar 255if not exist "%CATALINA_HOME%\endorsed" goto doneEndorsed 256set ENDORSED_PROP=java.endorsed.dirs 257:doneEndorsed 258 259rem ----- Execute The Requested Command --------------------------------------- 260 261echo Using CATALINA_BASE: "%CATALINA_BASE%" 262echo Using CATALINA_HOME: "%CATALINA_HOME%" 263echo Using CATALINA_TMPDIR: "%CATALINA_TMPDIR%" 264if ""%1"" == ""debug"" goto use_jdk 265echo Using JRE_HOME: "%JRE_HOME%" 266goto java_dir_displayed 267:use_jdk 268echo Using JAVA_HOME: "%JAVA_HOME%" 269:java_dir_displayed 270echo Using CLASSPATH: "%CLASSPATH%" 271echo Using CATALINA_OPTS: "%CATALINA_OPTS%" 272 273set _EXECJAVA=%_RUNJAVA% 274set MAINCLASS=org.apache.catalina.startup.Bootstrap 275set ACTION=start 276set SECURITY_POLICY_FILE= 277set DEBUG_OPTS= 278set JPDA= 279 280if not ""%1"" == ""jpda"" goto noJpda 281set JPDA=jpda 282if not "%JPDA_TRANSPORT%" == "" goto gotJpdaTransport 283set JPDA_TRANSPORT=dt_socket 284:gotJpdaTransport 285if not "%JPDA_ADDRESS%" == "" goto gotJpdaAddress 286set JPDA_ADDRESS=localhost:8000 287:gotJpdaAddress 288if not "%JPDA_SUSPEND%" == "" goto gotJpdaSuspend 289set JPDA_SUSPEND=n 290:gotJpdaSuspend 291if not "%JPDA_OPTS%" == "" goto gotJpdaOpts 292set JPDA_OPTS=-agentlib:jdwp=transport=%JPDA_TRANSPORT%,address=%JPDA_ADDRESS%,server=y,suspend=%JPDA_SUSPEND% 293:gotJpdaOpts 294shift 295:noJpda 296 297if ""%1"" == ""debug"" goto doDebug 298if ""%1"" == ""run"" goto doRun 299if ""%1"" == ""start"" goto doStart 300if ""%1"" == ""stop"" goto doStop 301if ""%1"" == ""configtest"" goto doConfigTest 302if ""%1"" == ""version"" goto doVersion 303 304echo Usage: catalina ( commands ... ) 305echo commands: 306echo debug Start Catalina in a debugger 307echo debug -security Debug Catalina with a security manager 308echo jpda start Start Catalina under JPDA debugger 309echo run Start Catalina in the current window 310echo run -security Start in the current window with security manager 311echo start Start Catalina in a separate window 312echo start -security Start in a separate window with security manager 313echo stop Stop Catalina 314echo configtest Run a basic syntax check on server.xml 315echo version What version of tomcat are you running? 316goto end 317 318:doDebug 319shift 320set _EXECJAVA=%_RUNJDB% 321set DEBUG_OPTS=-sourcepath "%CATALINA_HOME%\..\..\java" 322if not ""%1"" == ""-security"" goto execCmd 323shift 324echo Using Security Manager 325set "SECURITY_POLICY_FILE=%CATALINA_BASE%\conf\catalina.policy" 326goto execCmd 327 328:doRun 329shift 330if not ""%1"" == ""-security"" goto execCmd 331shift 332echo Using Security Manager 333set "SECURITY_POLICY_FILE=%CATALINA_BASE%\conf\catalina.policy" 334goto execCmd 335 336:doStart 337shift 338if "%TITLE%" == "" set TITLE=Tomcat 339set _EXECJAVA=start "%TITLE%" %_RUNJAVA% 340if not ""%1"" == ""-security"" goto execCmd 341shift 342echo Using Security Manager 343set "SECURITY_POLICY_FILE=%CATALINA_BASE%\conf\catalina.policy" 344goto execCmd 345 346:doStop 347shift 348set ACTION=stop 349set CATALINA_OPTS= 350goto execCmd 351 352:doConfigTest 353shift 354set ACTION=configtest 355set CATALINA_OPTS= 356goto execCmd 357 358:doVersion 359%_EXECJAVA% -classpath "%CATALINA_HOME%\lib\catalina.jar" org.apache.catalina.util.ServerInfo 360goto end 361 362 363:execCmd 364rem Get remaining unshifted command line arguments and save them in the 365set CMD_LINE_ARGS= 366:setArgs 367if ""%1""=="""" goto doneSetArgs 368set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 369shift 370goto setArgs 371:doneSetArgs 372 373rem Execute Java with the applicable properties 374if not "%JPDA%" == "" goto doJpda 375if not "%SECURITY_POLICY_FILE%" == "" goto doSecurity 376%_EXECJAVA% %CATALINA_LOGGING_CONFIG% %LOGGING_MANAGER% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -D%ENDORSED_PROP%="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION% 377goto end 378:doSecurity 379%_EXECJAVA% %CATALINA_LOGGING_CONFIG% %LOGGING_MANAGER% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -D%ENDORSED_PROP%="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Djava.security.manager -Djava.security.policy=="%SECURITY_POLICY_FILE%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION% 380goto end 381:doJpda 382if not "%SECURITY_POLICY_FILE%" == "" goto doSecurityJpda 383%_EXECJAVA% %CATALINA_LOGGING_CONFIG% %LOGGING_MANAGER% %JAVA_OPTS% %JPDA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -D%ENDORSED_PROP%="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION% 384goto end 385:doSecurityJpda 386%_EXECJAVA% %CATALINA_LOGGING_CONFIG% %LOGGING_MANAGER% %JAVA_OPTS% %JPDA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -D%ENDORSED_PROP%="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Djava.security.manager -Djava.security.policy=="%SECURITY_POLICY_FILE%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION% 387goto end 388 389:end 390