tomcat-cms升级为7.0.85
diff --git a/bin/bootstrap.jar b/bin/bootstrap.jar
index 7ed72fb..31a10e2 100644
--- a/bin/bootstrap.jar
+++ b/bin/bootstrap.jar
Binary files differ
diff --git a/bin/catalina-tasks.xml b/bin/catalina-tasks.xml
index c121d9b..4e6a8ae 100644
--- a/bin/catalina-tasks.xml
+++ b/bin/catalina-tasks.xml
@@ -1,47 +1,39 @@
-<?xml version="1.0"?>

-<!--

- Licensed to the Apache Software Foundation (ASF) under one or more

-  contributor license agreements.  See the NOTICE file distributed with

-  this work for additional information regarding copyright ownership.

-  The ASF licenses this file to You under the Apache License, Version 2.0

-  (the "License"); you may not use this file except in compliance with

-  the License.  You may obtain a copy of the License at

-

-      http://www.apache.org/licenses/LICENSE-2.0

-

-  Unless required by applicable law or agreed to in writing, software

-  distributed under the License is distributed on an "AS IS" BASIS,

-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

-  See the License for the specific language governing permissions and

-  limitations under the License.

--->

-<!--

-  XML file for importing Catalina ant tasks.

-  <import file="${catalina.home}/bin/catalina-tasks.xml"/>

--->

-

-<project name="catalina-tasks">

-  <description>Catalina Ant Manager, JMX and JSPC Tasks</description>

-  <!-- set catalina.home if it's not already set -->

-  <dirname property="catalina.home.bin.dir" file="${ant.file.catalina-tasks}"/>

-  <property name="catalina.home" value="${catalina.home.bin.dir}/.."/>

-  <typedef resource="org/apache/catalina/ant/catalina.tasks">

-    <classpath>

-      <fileset file="${catalina.home}/bin/tomcat-juli.jar"/>

-      <fileset file="${catalina.home}/lib/tomcat-api.jar"/>

-      <fileset file="${catalina.home}/lib/tomcat-util.jar"/>

-      <fileset file="${catalina.home}/lib/jasper.jar"/>

-      <fileset file="${catalina.home}/lib/jasper-el.jar"/>

-      <fileset file="${catalina.home}/lib/el-api.jar"/>

-      <fileset file="${catalina.home}/lib/jsp-api.jar"/>

-      <fileset file="${catalina.home}/lib/servlet-api.jar"/>

-      <fileset file="${catalina.home}/lib/catalina-ant.jar"/>

-      <fileset file="${catalina.home}/lib/tomcat-coyote.jar"/>

-    </classpath>

-  </typedef>

-  <typedef resource="org/apache/catalina/ant/jmx/jmxaccessor.tasks">

-    <classpath>

-      <fileset file="${catalina.home}/lib/catalina-ant.jar"/>

-    </classpath>

-  </typedef>

-</project>

+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!--
+  XML file for importing Catalina ant tasks.
+  <import file="${catalina.home}/bin/catalina-tasks.xml"/>
+-->
+
+<project name="catalina-tasks">
+  <description>Catalina Ant Manager, JMX and JSPC Tasks</description>
+  <!-- set catalina.home if it's not already set -->
+  <dirname property="catalina.home.bin.dir" file="${ant.file.catalina-tasks}"/>
+  <property name="catalina.home" value="${catalina.home.bin.dir}/.."/>
+  <typedef resource="org/apache/catalina/ant/catalina.tasks">
+    <classpath>
+      <fileset file="${catalina.home}/bin/tomcat-juli.jar"/>
+      <fileset dir="${catalina.home}/lib" includes="*.jar"/>
+    </classpath>
+  </typedef>
+  <typedef resource="org/apache/catalina/ant/jmx/jmxaccessor.tasks">
+    <classpath>
+      <fileset file="${catalina.home}/lib/catalina-ant.jar"/>
+    </classpath>
+  </typedef>
+</project>
diff --git a/bin/catalina.bat b/bin/catalina.bat
index 1bf315d..e70c14a 100644
--- a/bin/catalina.bat
+++ b/bin/catalina.bat
@@ -14,7 +14,6 @@
 rem See the License for the specific language governing permissions and

 rem limitations under the License.

 

-if "%OS%" == "Windows_NT" setlocal

 rem ---------------------------------------------------------------------------

 rem Start/Stop Script for the CATALINA Server

 rem

@@ -23,6 +22,16 @@
 rem   Do not set the variables in this script. Instead put them into a script

 rem   setenv.bat in CATALINA_BASE/bin to keep your customizations separate.

 rem

+rem   WHEN RUNNING TOMCAT AS A WINDOWS SERVICE:

+rem   Note that the environment variables that affect the behavior of this

+rem   script will have no effect at all on Windows Services. As such, any

+rem   local customizations made in a CATALINA_BASE/bin/setenv.bat script

+rem   will also have no effect on Tomcat when launched as a Windows Service.

+rem   The configuration that controls Windows Services is stored in the Windows

+rem   Registry, and is most conveniently maintained using the "tomcatXw.exe"

+rem   maintenance utility, where "X" is the major version of Tomcat you are

+rem   running.

+rem

 rem   CATALINA_HOME   May point at your Catalina "build" directory.

 rem

 rem   CATALINA_BASE   (Optional) Base directory for resolving dynamic portions

@@ -58,6 +67,7 @@
 rem                   containing some jars in order to allow replacement of APIs

 rem                   created outside of the JCP (i.e. DOM and SAX from W3C).

 rem                   It can also be used to update the XML parser implementation.

+rem                   Note that Java 9 no longer supports this feature.

 rem                   Defaults to $CATALINA_HOME/endorsed.

 rem

 rem   JPDA_TRANSPORT  (Optional) JPDA transport used when the "jpda start"

@@ -78,6 +88,10 @@
 rem                   -agentlib:jdwp=transport=%JPDA_TRANSPORT%,

 rem                       address=%JPDA_ADDRESS%,server=y,suspend=%JPDA_SUSPEND%

 rem

+rem   JSSE_OPTS       (Optional) Java runtime options used to control the TLS

+rem                   implementation when JSSE is used. Default is:

+rem                   "-Djdk.tls.ephemeralDHKeySize=2048"

+rem

 rem   LOGGING_CONFIG  (Optional) Override Tomcat's logging config file

 rem                   Example (all one line)

 rem                   set LOGGING_CONFIG="-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties"

@@ -90,12 +104,10 @@
 rem                   TITLE is Tomcat if it's not specified.

 rem                   Example (all one line)

 rem                   set TITLE=Tomcat.Cluster#1.Server#1 [%DATE% %TIME%]

-rem

-rem

-rem

-rem $Id: catalina.bat 1344732 2012-05-31 14:08:02Z kkolinko $

 rem ---------------------------------------------------------------------------

 

+setlocal

+

 rem Suppress Terminate batch job on CTRL+C

 if not ""%1"" == ""run"" goto mainEntry

 if "%TEMP%" == "" goto mainEntry

@@ -174,17 +186,37 @@
 set "CLASSPATH=%CLASSPATH%;%CATALINA_HOME%\bin\tomcat-juli.jar"

 :juliClasspathDone

 

+if not "%JSSE_OPTS%" == "" goto gotJsseOpts

+set JSSE_OPTS="-Djdk.tls.ephemeralDHKeySize=2048"

+:gotJsseOpts

+set "JAVA_OPTS=%JAVA_OPTS% %JSSE_OPTS%"

+

 if not "%LOGGING_CONFIG%" == "" goto noJuliConfig

 set LOGGING_CONFIG=-Dnop

 if not exist "%CATALINA_BASE%\conf\logging.properties" goto noJuliConfig

 set LOGGING_CONFIG=-Djava.util.logging.config.file="%CATALINA_BASE%\conf\logging.properties"

 :noJuliConfig

-set JAVA_OPTS=%JAVA_OPTS% %LOGGING_CONFIG%

 

 if not "%LOGGING_MANAGER%" == "" goto noJuliManager

 set LOGGING_MANAGER=-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager

 :noJuliManager

-set JAVA_OPTS=%JAVA_OPTS% %LOGGING_MANAGER%

+

+rem Java 9 no longer supports the java.endorsed.dirs

+rem system property. Only try to use it if

+rem JAVA_ENDORSED_DIRS was explicitly set

+rem or CATALINA_HOME/endorsed exists.

+set ENDORSED_PROP=ignore.endorsed.dirs

+if "%JAVA_ENDORSED_DIRS%" == "" goto noEndorsedVar

+set ENDORSED_PROP=java.endorsed.dirs

+goto doneEndorsed

+:noEndorsedVar

+if not exist "%CATALINA_HOME%\endorsed" goto doneEndorsed

+set ENDORSED_PROP=java.endorsed.dirs

+:doneEndorsed

+

+rem Configure JAVA 9 specific start-up parameters

+set "JDK_JAVA_OPTIONS=%JDK_JAVA_OPTIONS% --add-opens=java.base/java.lang=ALL-UNNAMED"

+set "JDK_JAVA_OPTIONS=%JDK_JAVA_OPTIONS% --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED"

 

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

 

@@ -264,13 +296,8 @@
 

 :doStart

 shift

-if not "%OS%" == "Windows_NT" goto noTitle

 if "%TITLE%" == "" set TITLE=Tomcat

 set _EXECJAVA=start "%TITLE%" %_RUNJAVA%

-goto gotTitle

-:noTitle

-set _EXECJAVA=start %_RUNJAVA%

-:gotTitle

 if not ""%1"" == ""-security"" goto execCmd

 shift

 echo Using Security Manager

@@ -307,17 +334,17 @@
 rem Execute Java with the applicable properties

 if not "%JPDA%" == "" goto doJpda

 if not "%SECURITY_POLICY_FILE%" == "" goto doSecurity

-%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION%

+%_EXECJAVA% %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%

 goto end

 :doSecurity

-%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%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%

+%_EXECJAVA% %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%

 goto end

 :doJpda

 if not "%SECURITY_POLICY_FILE%" == "" goto doSecurityJpda

-%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %JPDA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION%

+%_EXECJAVA% %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%

 goto end

 :doSecurityJpda

-%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %JPDA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%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%

+%_EXECJAVA% %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%

 goto end

 

 :end

diff --git a/bin/catalina.sh b/bin/catalina.sh
index c8d5493..fa39688 100755
--- a/bin/catalina.sh
+++ b/bin/catalina.sh
@@ -62,6 +62,7 @@
 #                   containing some jars in order to allow replacement of APIs
 #                   created outside of the JCP (i.e. DOM and SAX from W3C).
 #                   It can also be used to update the XML parser implementation.
+#                   Note that Java 9 no longer supports this feature.
 #                   Defaults to $CATALINA_HOME/endorsed.
 #
 #   JPDA_TRANSPORT  (Optional) JPDA transport used when the "jpda start"
@@ -82,6 +83,10 @@
 #                   -agentlib:jdwp=transport=$JPDA_TRANSPORT,
 #                       address=$JPDA_ADDRESS,server=y,suspend=$JPDA_SUSPEND
 #
+#   JSSE_OPTS       (Optional) Java runtime options used to control the TLS
+#                   implementation when JSSE is used. Default is:
+#                   "-Djdk.tls.ephemeralDHKeySize=2048"
+#
 #   CATALINA_PID    (Optional) Path of the file which should contains the pid
 #                   of the catalina startup java process, when start (fork) is
 #                   used
@@ -94,17 +99,22 @@
 #                   Example (all one line)
 #                   LOGGING_MANAGER="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
 #
-# $Id: catalina.sh 1498485 2013-07-01 14:37:43Z markt $
+#   USE_NOHUP       (Optional) If set to the string true the start command will
+#                   use nohup so that the Tomcat process will ignore any hangup
+#                   signals. Default is "false" unless running on HP-UX in which
+#                   case the default is "true"
 # -----------------------------------------------------------------------------
 
 # OS specific support.  $var _must_ be set to either true or false.
 cygwin=false
 darwin=false
 os400=false
+hpux=false
 case "`uname`" in
 CYGWIN*) cygwin=true;;
 Darwin*) darwin=true;;
 OS400*) os400=true;;
+HP-UX*) hpux=true;;
 esac
 
 # resolve links - $0 may be a softlink
@@ -217,6 +227,11 @@
   JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"`
 fi
 
+if [ -z "$JSSE_OPTS" ] ; then
+  JSSE_OPTS="-Djdk.tls.ephemeralDHKeySize=2048"
+fi
+JAVA_OPTS="$JAVA_OPTS $JSSE_OPTS"
+
 # Set juli LogManager config file if it is present and an override has not been issued
 if [ -z "$LOGGING_CONFIG" ]; then
   if [ -r "$CATALINA_BASE"/conf/logging.properties ]; then
@@ -231,10 +246,39 @@
   LOGGING_MANAGER="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
 fi
 
+# Java 9 no longer supports the java.endorsed.dirs
+# system property. Only try to use it if
+# JAVA_ENDORSED_DIRS was explicitly set
+# or CATALINA_HOME/endorsed exists.
+ENDORSED_PROP=ignore.endorsed.dirs
+if [ -n "$JAVA_ENDORSED_DIRS" ]; then
+    ENDORSED_PROP=java.endorsed.dirs
+fi
+if [ -d "$CATALINA_HOME/endorsed" ]; then
+    ENDORSED_PROP=java.endorsed.dirs
+fi
+
 # Uncomment the following line to make the umask available when using the
 # org.apache.catalina.security.SecurityListener
 #JAVA_OPTS="$JAVA_OPTS -Dorg.apache.catalina.security.SecurityListener.UMASK=`umask`"
 
+if [ -z "$USE_NOHUP" ]; then
+    if $hpux; then
+        USE_NOHUP="true"
+    else
+        USE_NOHUP="false"
+    fi
+fi
+unset _NOHUP
+if [ "$USE_NOHUP" = "true" ]; then
+    _NOHUP=nohup
+fi
+
+# Add the JAVA 9 specific start-up parameters required by Tomcat
+JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=java.base/java.lang=ALL-UNNAMED"
+JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED"
+export JDK_JAVA_OPTIONS
+
 # ----- Execute The Requested Command -----------------------------------------
 
 # Bugzilla 37848: only output this if we have a TTY
@@ -266,7 +310,7 @@
   if [ -z "$JPDA_OPTS" ]; then
     JPDA_OPTS="-agentlib:jdwp=transport=$JPDA_TRANSPORT,address=$JPDA_ADDRESS,server=y,suspend=$JPDA_SUSPEND"
   fi
-  CATALINA_OPTS="$CATALINA_OPTS $JPDA_OPTS"
+  CATALINA_OPTS="$JPDA_OPTS $CATALINA_OPTS"
   shift
 fi
 
@@ -282,7 +326,8 @@
       fi
       shift
       exec "$_RUNJDB" "$LOGGING_CONFIG" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
-        -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
+        -D$ENDORSED_PROP="$JAVA_ENDORSED_DIRS" \
+        -classpath "$CLASSPATH" \
         -sourcepath "$CATALINA_HOME"/../../java \
         -Djava.security.manager \
         -Djava.security.policy=="$CATALINA_BASE"/conf/catalina.policy \
@@ -292,7 +337,8 @@
         org.apache.catalina.startup.Bootstrap "$@" start
     else
       exec "$_RUNJDB" "$LOGGING_CONFIG" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
-        -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
+        -D$ENDORSED_PROP="$JAVA_ENDORSED_DIRS" \
+        -classpath "$CLASSPATH" \
         -sourcepath "$CATALINA_HOME"/../../java \
         -Dcatalina.base="$CATALINA_BASE" \
         -Dcatalina.home="$CATALINA_HOME" \
@@ -309,20 +355,22 @@
       echo "Using Security Manager"
     fi
     shift
-    eval exec \"$_RUNJAVA\" \"$LOGGING_CONFIG\" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
-      -Djava.endorsed.dirs=\"$JAVA_ENDORSED_DIRS\" -classpath \"$CLASSPATH\" \
+    eval exec "\"$_RUNJAVA\"" "\"$LOGGING_CONFIG\"" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
+      -D$ENDORSED_PROP="\"$JAVA_ENDORSED_DIRS\"" \
+      -classpath "\"$CLASSPATH\"" \
       -Djava.security.manager \
-      -Djava.security.policy==\"$CATALINA_BASE/conf/catalina.policy\" \
-      -Dcatalina.base=\"$CATALINA_BASE\" \
-      -Dcatalina.home=\"$CATALINA_HOME\" \
-      -Djava.io.tmpdir=\"$CATALINA_TMPDIR\" \
+      -Djava.security.policy=="\"$CATALINA_BASE/conf/catalina.policy\"" \
+      -Dcatalina.base="\"$CATALINA_BASE\"" \
+      -Dcatalina.home="\"$CATALINA_HOME\"" \
+      -Djava.io.tmpdir="\"$CATALINA_TMPDIR\"" \
       org.apache.catalina.startup.Bootstrap "$@" start
   else
-    eval exec \"$_RUNJAVA\" \"$LOGGING_CONFIG\" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
-      -Djava.endorsed.dirs=\"$JAVA_ENDORSED_DIRS\" -classpath \"$CLASSPATH\" \
-      -Dcatalina.base=\"$CATALINA_BASE\" \
-      -Dcatalina.home=\"$CATALINA_HOME\" \
-      -Djava.io.tmpdir=\"$CATALINA_TMPDIR\" \
+    eval exec "\"$_RUNJAVA\"" "\"$LOGGING_CONFIG\"" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
+      -D$ENDORSED_PROP="\"$JAVA_ENDORSED_DIRS\"" \
+      -classpath "\"$CLASSPATH\"" \
+      -Dcatalina.base="\"$CATALINA_BASE\"" \
+      -Dcatalina.home="\"$CATALINA_HOME\"" \
+      -Djava.io.tmpdir="\"$CATALINA_TMPDIR\"" \
       org.apache.catalina.startup.Bootstrap "$@" start
   fi
 
@@ -337,6 +385,8 @@
           ps -p $PID >/dev/null 2>&1
           if [ $? -eq 0 ] ; then
             echo "Tomcat appears to still be running with PID $PID. Start aborted."
+            echo "If the following process is not a Tomcat process, remove the PID file and try again:"
+            ps -f -p $PID
             exit 1
           else
             echo "Removing/clearing stale PID file."
@@ -373,22 +423,24 @@
       echo "Using Security Manager"
     fi
     shift
-    eval \"$_RUNJAVA\" \"$LOGGING_CONFIG\" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
-      -Djava.endorsed.dirs=\"$JAVA_ENDORSED_DIRS\" -classpath \"$CLASSPATH\" \
+    eval $_NOHUP "\"$_RUNJAVA\"" "\"$LOGGING_CONFIG\"" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
+      -D$ENDORSED_PROP="\"$JAVA_ENDORSED_DIRS\"" \
+      -classpath "\"$CLASSPATH\"" \
       -Djava.security.manager \
-      -Djava.security.policy==\"$CATALINA_BASE/conf/catalina.policy\" \
-      -Dcatalina.base=\"$CATALINA_BASE\" \
-      -Dcatalina.home=\"$CATALINA_HOME\" \
-      -Djava.io.tmpdir=\"$CATALINA_TMPDIR\" \
+      -Djava.security.policy=="\"$CATALINA_BASE/conf/catalina.policy\"" \
+      -Dcatalina.base="\"$CATALINA_BASE\"" \
+      -Dcatalina.home="\"$CATALINA_HOME\"" \
+      -Djava.io.tmpdir="\"$CATALINA_TMPDIR\"" \
       org.apache.catalina.startup.Bootstrap "$@" start \
       >> "$CATALINA_OUT" 2>&1 "&"
 
   else
-    eval \"$_RUNJAVA\" \"$LOGGING_CONFIG\" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
-      -Djava.endorsed.dirs=\"$JAVA_ENDORSED_DIRS\" -classpath \"$CLASSPATH\" \
-      -Dcatalina.base=\"$CATALINA_BASE\" \
-      -Dcatalina.home=\"$CATALINA_HOME\" \
-      -Djava.io.tmpdir=\"$CATALINA_TMPDIR\" \
+    eval $_NOHUP "\"$_RUNJAVA\"" "\"$LOGGING_CONFIG\"" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
+      -D$ENDORSED_PROP="\"$JAVA_ENDORSED_DIRS\"" \
+      -classpath "\"$CLASSPATH\"" \
+      -Dcatalina.base="\"$CATALINA_BASE\"" \
+      -Dcatalina.home="\"$CATALINA_HOME\"" \
+      -Djava.io.tmpdir="\"$CATALINA_TMPDIR\"" \
       org.apache.catalina.startup.Bootstrap "$@" start \
       >> "$CATALINA_OUT" 2>&1 "&"
 
@@ -398,6 +450,8 @@
     echo $! > "$CATALINA_PID"
   fi
 
+  echo "Tomcat started."
+
 elif [ "$1" = "stop" ] ; then
 
   shift
@@ -434,13 +488,22 @@
     fi
   fi
 
-  eval \"$_RUNJAVA\" $LOGGING_MANAGER $JAVA_OPTS \
-    -Djava.endorsed.dirs=\"$JAVA_ENDORSED_DIRS\" -classpath \"$CLASSPATH\" \
-    -Dcatalina.base=\"$CATALINA_BASE\" \
-    -Dcatalina.home=\"$CATALINA_HOME\" \
-    -Djava.io.tmpdir=\"$CATALINA_TMPDIR\" \
+  eval "\"$_RUNJAVA\"" $LOGGING_MANAGER $JAVA_OPTS \
+    -D$ENDORSED_PROP="\"$JAVA_ENDORSED_DIRS\"" \
+    -classpath "\"$CLASSPATH\"" \
+    -Dcatalina.base="\"$CATALINA_BASE\"" \
+    -Dcatalina.home="\"$CATALINA_HOME\"" \
+    -Djava.io.tmpdir="\"$CATALINA_TMPDIR\"" \
     org.apache.catalina.startup.Bootstrap "$@" stop
 
+  # stop failed. Shutdown port disabled? Try a normal kill.
+  if [ $? != 0 ]; then
+    if [ ! -z "$CATALINA_PID" ]; then
+      echo "The stop command failed. Attempting to signal the process to stop through OS signal."
+      kill -15 `cat "$CATALINA_PID"` >/dev/null 2>&1
+    fi
+  fi
+
   if [ ! -z "$CATALINA_PID" ]; then
     if [ -f "$CATALINA_PID" ]; then
       while [ $SLEEP -ge 0 ]; do
@@ -450,19 +513,25 @@
           if [ $? != 0 ]; then
             if [ -w "$CATALINA_PID" ]; then
               cat /dev/null > "$CATALINA_PID"
+              # If Tomcat has stopped don't try and force a stop with an empty PID file
+              FORCE=0
             else
-              echo "Tomcat stopped but the PID file could not be removed or cleared."
+              echo "The PID file could not be removed or cleared."
             fi
           fi
+          echo "Tomcat stopped."
           break
         fi
         if [ $SLEEP -gt 0 ]; then
           sleep 1
         fi
         if [ $SLEEP -eq 0 ]; then
+          echo "Tomcat did not stop in time."
           if [ $FORCE -eq 0 ]; then
-            echo "Tomcat did not stop in time. PID file was not removed."
+            echo "PID file was not removed."
           fi
+          echo "To aid diagnostics a thread dump has been written to standard out."
+          kill -3 `cat "$CATALINA_PID"`
         fi
         SLEEP=`expr $SLEEP - 1 `
       done
@@ -483,8 +552,13 @@
             if [ $? -gt 0 ]; then
                 rm -f "$CATALINA_PID" >/dev/null 2>&1
                 if [ $? != 0 ]; then
-                    echo "Tomcat was killed but the PID file could not be removed."
+                    if [ -w "$CATALINA_PID" ]; then
+                        cat /dev/null > "$CATALINA_PID"
+                    else
+                        echo "The PID file could not be removed."
+                    fi
                 fi
+                echo "The Tomcat process has been killed."
                 break
             fi
             if [ $KILL_SLEEP_INTERVAL -gt 0 ]; then
@@ -492,7 +566,7 @@
             fi
             KILL_SLEEP_INTERVAL=`expr $KILL_SLEEP_INTERVAL - 1 `
         done
-        if [ $KILL_SLEEP_INTERVAL -gt 0 ]; then
+        if [ $KILL_SLEEP_INTERVAL -lt 0 ]; then
             echo "Tomcat has not been killed completely yet. The process might be waiting on some system call or might be UNINTERRUPTIBLE."
         fi
       fi
@@ -501,11 +575,12 @@
 
 elif [ "$1" = "configtest" ] ; then
 
-    eval \"$_RUNJAVA\" $LOGGING_MANAGER $JAVA_OPTS \
-      -Djava.endorsed.dirs=\"$JAVA_ENDORSED_DIRS\" -classpath \"$CLASSPATH\" \
-      -Dcatalina.base=\"$CATALINA_BASE\" \
-      -Dcatalina.home=\"$CATALINA_HOME\" \
-      -Djava.io.tmpdir=\"$CATALINA_TMPDIR\" \
+    eval "\"$_RUNJAVA\"" $LOGGING_MANAGER $JAVA_OPTS \
+      -D$ENDORSED_PROP="\"$JAVA_ENDORSED_DIRS\"" \
+      -classpath "\"$CLASSPATH\"" \
+      -Dcatalina.base="\"$CATALINA_BASE\"" \
+      -Dcatalina.home="\"$CATALINA_HOME\"" \
+      -Djava.io.tmpdir="\"$CATALINA_TMPDIR\"" \
       org.apache.catalina.startup.Bootstrap configtest
     result=$?
     if [ $result -ne 0 ]; then
diff --git a/bin/commons-daemon-native.tar.gz b/bin/commons-daemon-native.tar.gz
index 6d25918..39cfff5 100644
--- a/bin/commons-daemon-native.tar.gz
+++ b/bin/commons-daemon-native.tar.gz
Binary files differ
diff --git a/bin/commons-daemon.jar b/bin/commons-daemon.jar
index 2b6b9c6..173f67f 100644
--- a/bin/commons-daemon.jar
+++ b/bin/commons-daemon.jar
Binary files differ
diff --git a/bin/configtest.bat b/bin/configtest.bat
index c3bfd89..02448e1 100644
--- a/bin/configtest.bat
+++ b/bin/configtest.bat
@@ -14,13 +14,12 @@
 rem See the License for the specific language governing permissions and

 rem limitations under the License.

 

-if "%OS%" == "Windows_NT" setlocal

 rem ---------------------------------------------------------------------------

 rem Configuration test script for the CATALINA Server

-rem

-rem $Id: configtest.bat 1137560 2011-06-20 09:27:44Z rjung $

 rem ---------------------------------------------------------------------------

 

+setlocal

+

 rem Guess CATALINA_HOME if not defined

 set "CURRENT_DIR=%cd%"

 if not "%CATALINA_HOME%" == "" goto gotHome

diff --git a/bin/configtest.sh b/bin/configtest.sh
index f084e78..9a8ebff 100755
--- a/bin/configtest.sh
+++ b/bin/configtest.sh
@@ -17,8 +17,6 @@
 
 # -----------------------------------------------------------------------------
 # Configuration Test Script for the CATALINA Server
-#
-# $Id: configtest.sh 1202062 2011-11-15 06:50:02Z mturk $
 # -----------------------------------------------------------------------------
 
 # Better OS/400 detection: see Bugzilla 31132
diff --git a/bin/daemon.sh b/bin/daemon.sh
index 9a4640d..ef9f708 100755
--- a/bin/daemon.sh
+++ b/bin/daemon.sh
@@ -17,8 +17,6 @@
 #
 # -----------------------------------------------------------------------------
 # Commons Daemon wrapper script.
-#
-# $Id: daemon.sh 1202058 2011-11-15 06:37:12Z mturk $
 # -----------------------------------------------------------------------------
 #
 # resolve links - $0 may be a softlink
@@ -62,6 +60,11 @@
         shift; shift;
         continue
     ;;
+    --service-start-wait-time )
+        SERVICE_START_WAIT_TIME="$2"
+        shift; shift;
+        continue
+    ;;
     * )
         break
     ;;
@@ -91,6 +94,15 @@
 #
 if [ -z "$JAVA_HOME" ]; then
     JAVA_BIN="`which java 2>/dev/null || type java 2>&1`"
+    while [ -h "$JAVA_BIN" ]; do
+        ls=`ls -ld "$JAVA_BIN"`
+        link=`expr "$ls" : '.*-> \(.*\)$'`
+        if expr "$link" : '/.*' > /dev/null; then
+            JAVA_BIN="$link"
+        else
+            JAVA_BIN="`dirname $JAVA_BIN`/$link"
+        fi
+    done
     test -x "$JAVA_BIN" && JAVA_HOME="`dirname $JAVA_BIN`"
     test ".$JAVA_HOME" != . && JAVA_HOME=`cd "$JAVA_HOME/.." >/dev/null; pwd`
 else
@@ -101,7 +113,15 @@
 test ".$CATALINA_HOME" = . && CATALINA_HOME=`cd "$DIRNAME/.." >/dev/null; pwd`
 test ".$CATALINA_BASE" = . && CATALINA_BASE="$CATALINA_HOME"
 test ".$CATALINA_MAIN" = . && CATALINA_MAIN=org.apache.catalina.startup.Bootstrap
-test ".$JSVC" = . && JSVC="$CATALINA_BASE/bin/jsvc"
+# If not explicitly set, look for jsvc in CATALINA_BASE first then CATALINA_HOME
+if [ -z "$JSVC" ]; then
+    JSVC="$CATALINA_BASE/bin/jsvc"
+    if [ ! -x "$JSVC" ]; then
+        JSVC="$CATALINA_HOME/bin/jsvc"
+    fi
+fi
+# Set the default service-start wait time if necessary
+test ".$SERVICE_START_WAIT_TIME" = . && SERVICE_START_WAIT_TIME=10
 
 # Ensure that any user defined CLASSPATH variables are not used on startup,
 # but allow them to be specified in setenv.sh, in rare case when it is needed.
@@ -161,6 +181,18 @@
     fi
 fi
 
+# Java 9 no longer supports the java.endorsed.dirs
+# system property. Only try to use it if
+# JAVA_ENDORSED_DIRS was explicitly set
+# or CATALINA_HOME/endorsed exists.
+ENDORSED_PROP=ignore.endorsed.dirs
+if [ -n "$JAVA_ENDORSED_DIRS" ]; then
+    ENDORSED_PROP=java.endorsed.dirs
+fi
+if [ -d "$CATALINA_HOME/endorsed" ]; then
+    ENDORSED_PROP=java.endorsed.dirs
+fi
+
 # ----- Execute The Requested Command -----------------------------------------
 case "$1" in
     run     )
@@ -169,13 +201,13 @@
       $JSVC_OPTS \
       -java-home "$JAVA_HOME" \
       -pidfile "$CATALINA_PID" \
-      -wait 10 \
+      -wait "$SERVICE_START_WAIT_TIME" \
       -nodetach \
       -outfile "&1" \
       -errfile "&2" \
       -classpath "$CLASSPATH" \
       "$LOGGING_CONFIG" $JAVA_OPTS $CATALINA_OPTS \
-      -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" \
+      -D$ENDORSED_PROP="$JAVA_ENDORSED_DIRS" \
       -Dcatalina.base="$CATALINA_BASE" \
       -Dcatalina.home="$CATALINA_HOME" \
       -Djava.io.tmpdir="$CATALINA_TMP" \
@@ -187,12 +219,12 @@
       -java-home "$JAVA_HOME" \
       -user $TOMCAT_USER \
       -pidfile "$CATALINA_PID" \
-      -wait 10 \
+      -wait "$SERVICE_START_WAIT_TIME" \
       -outfile "$CATALINA_OUT" \
       -errfile "&1" \
       -classpath "$CLASSPATH" \
       "$LOGGING_CONFIG" $JAVA_OPTS $CATALINA_OPTS \
-      -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" \
+      -D$ENDORSED_PROP="$JAVA_ENDORSED_DIRS" \
       -Dcatalina.base="$CATALINA_BASE" \
       -Dcatalina.home="$CATALINA_HOME" \
       -Djava.io.tmpdir="$CATALINA_TMP" \
@@ -204,7 +236,7 @@
       -stop \
       -pidfile "$CATALINA_PID" \
       -classpath "$CLASSPATH" \
-      -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" \
+      -D$ENDORSED_PROP="$JAVA_ENDORSED_DIRS" \
       -Dcatalina.base="$CATALINA_BASE" \
       -Dcatalina.home="$CATALINA_HOME" \
       -Djava.io.tmpdir="$CATALINA_TMP" \
diff --git a/bin/digest.bat b/bin/digest.bat
index 41491dc..428b9d1 100644
--- a/bin/digest.bat
+++ b/bin/digest.bat
@@ -14,13 +14,12 @@
 rem See the License for the specific language governing permissions and

 rem limitations under the License.

 

-if "%OS%" == "Windows_NT" setlocal

 rem ---------------------------------------------------------------------------

 rem Script to digest password using the algorithm specified

-rem

-rem $Id: digest.bat 1137559 2011-06-20 09:27:30Z rjung $

 rem ---------------------------------------------------------------------------

 

+setlocal

+

 rem Guess CATALINA_HOME if not defined

 set "CURRENT_DIR=%cd%"

 if not "%CATALINA_HOME%" == "" goto gotHome

diff --git a/bin/digest.sh b/bin/digest.sh
index 7aa0c40..62ed5d0 100755
--- a/bin/digest.sh
+++ b/bin/digest.sh
@@ -17,8 +17,6 @@
 
 # -----------------------------------------------------------------------------
 # Script to digest password using the algorithm specified
-#
-# $Id: digest.sh 1202062 2011-11-15 06:50:02Z mturk $
 # -----------------------------------------------------------------------------
 
 # Better OS/400 detection: see Bugzilla 31132
diff --git a/bin/setclasspath.bat b/bin/setclasspath.bat
index e29b41a..2cf4610 100644
--- a/bin/setclasspath.bat
+++ b/bin/setclasspath.bat
@@ -18,8 +18,6 @@
 rem Set JAVA_HOME or JRE_HOME if not already set, ensure any provided settings

 rem are valid and consistent with the selected start-up options and set up the

 rem endorsed directory.

-rem

-rem $Id: setclasspath.bat 1202062 2011-11-15 06:50:02Z mturk $

 rem ---------------------------------------------------------------------------

 

 rem Make sure prerequisite environment variables are set

@@ -69,15 +67,25 @@
 :okJava

 rem Don't override the endorsed dir if the user has set it previously

 if not "%JAVA_ENDORSED_DIRS%" == "" goto gotEndorseddir

-rem Set the default -Djava.endorsed.dirs argument

+rem Java 9 no longer supports the java.endorsed.dirs

+rem system property. Only try to use it if

+rem CATALINA_HOME/endorsed exists.

+if not exist "%CATALINA_HOME%\endorsed" goto gotEndorseddir

 set "JAVA_ENDORSED_DIRS=%CATALINA_HOME%\endorsed"

 :gotEndorseddir

 

+rem Don't override _RUNJAVA if the user has set it previously

+if not "%_RUNJAVA%" == "" goto gotRunJava

 rem Set standard command for invoking Java.

-rem Note that NT requires a window name argument when using start.

+rem Also note the quoting as JRE_HOME may contain spaces.

+set _RUNJAVA="%JRE_HOME%\bin\java.exe"

+:gotRunJava

+

+rem Don't override _RUNJDB if the user has set it previously

 rem Also note the quoting as JAVA_HOME may contain spaces.

-set _RUNJAVA="%JRE_HOME%\bin\java"

-set _RUNJDB="%JAVA_HOME%\bin\jdb"

+if not "%_RUNJDB%" == "" goto gotRunJdb

+set _RUNJDB="%JAVA_HOME%\bin\jdb.exe"

+:gotRunJdb

 

 goto end

 

diff --git a/bin/setclasspath.sh b/bin/setclasspath.sh
index b6c42dd..5232b8e 100755
--- a/bin/setclasspath.sh
+++ b/bin/setclasspath.sh
@@ -19,8 +19,6 @@
 #  Set JAVA_HOME or JRE_HOME if not already set, ensure any provided settings
 #  are valid and consistent with the selected start-up options and set up the
 #  endorsed directory.
-#
-#  $Id: setclasspath.sh 1430568 2013-01-08 22:08:57Z schultz $
 # -----------------------------------------------------------------------------
 
 # Make sure prerequisite environment variables are set
@@ -81,12 +79,20 @@
 
 # Don't override the endorsed dir if the user has set it previously
 if [ -z "$JAVA_ENDORSED_DIRS" ]; then
-  # Set the default -Djava.endorsed.dirs argument
-  JAVA_ENDORSED_DIRS="$CATALINA_HOME"/endorsed
+  # Java 9 no longer supports the java.endorsed.dirs
+  # system property. Only try to use it if
+  # CATALINA_HOME/endorsed exists.
+  if [ -d "$CATALINA_HOME"/endorsed ]; then
+    JAVA_ENDORSED_DIRS="$CATALINA_HOME"/endorsed
+  fi
 fi
 
-# Set standard commands for invoking Java.
-_RUNJAVA="$JRE_HOME"/bin/java
+# Set standard commands for invoking Java, if not already set.
+if [ -z "$_RUNJAVA" ]; then
+  _RUNJAVA="$JRE_HOME"/bin/java
+fi
 if [ "$os400" != "true" ]; then
-  _RUNJDB="$JAVA_HOME"/bin/jdb
+  if [ -z "$_RUNJDB" ]; then
+    _RUNJDB="$JAVA_HOME"/bin/jdb
+  fi
 fi
diff --git a/bin/shutdown.bat b/bin/shutdown.bat
index 0f30951..119fb99 100644
--- a/bin/shutdown.bat
+++ b/bin/shutdown.bat
@@ -14,13 +14,12 @@
 rem See the License for the specific language governing permissions and

 rem limitations under the License.

 

-if "%OS%" == "Windows_NT" setlocal

 rem ---------------------------------------------------------------------------

 rem Stop script for the CATALINA Server

-rem

-rem $Id: shutdown.bat 895392 2010-01-03 14:02:31Z kkolinko $

 rem ---------------------------------------------------------------------------

 

+setlocal

+

 rem Guess CATALINA_HOME if not defined

 set "CURRENT_DIR=%cd%"

 if not "%CATALINA_HOME%" == "" goto gotHome

diff --git a/bin/shutdown.sh b/bin/shutdown.sh
index ca243f6..cd0c97d 100755
--- a/bin/shutdown.sh
+++ b/bin/shutdown.sh
@@ -17,8 +17,6 @@
 
 # -----------------------------------------------------------------------------
 # Stop script for the CATALINA Server
-#
-# $Id: shutdown.sh 1202062 2011-11-15 06:50:02Z mturk $
 # -----------------------------------------------------------------------------
 
 # Better OS/400 detection: see Bugzilla 31132
diff --git a/bin/startup.bat b/bin/startup.bat
index d9ce1ac..e9f46b8 100644
--- a/bin/startup.bat
+++ b/bin/startup.bat
@@ -14,13 +14,12 @@
 rem See the License for the specific language governing permissions and

 rem limitations under the License.

 

-if "%OS%" == "Windows_NT" setlocal

 rem ---------------------------------------------------------------------------

 rem Start script for the CATALINA Server

-rem

-rem $Id: startup.bat 895392 2010-01-03 14:02:31Z kkolinko $

 rem ---------------------------------------------------------------------------

 

+setlocal

+

 rem Guess CATALINA_HOME if not defined

 set "CURRENT_DIR=%cd%"

 if not "%CATALINA_HOME%" == "" goto gotHome

diff --git a/bin/startup.sh b/bin/startup.sh
index 3fd902d..7b10287 100755
--- a/bin/startup.sh
+++ b/bin/startup.sh
@@ -17,8 +17,6 @@
 
 # -----------------------------------------------------------------------------
 # Start Script for the CATALINA Server
-#
-# $Id: startup.sh 1202062 2011-11-15 06:50:02Z mturk $
 # -----------------------------------------------------------------------------
 
 # Better OS/400 detection: see Bugzilla 31132
diff --git a/bin/tomcat-juli.jar b/bin/tomcat-juli.jar
index 3a6755b..995d3e5 100644
--- a/bin/tomcat-juli.jar
+++ b/bin/tomcat-juli.jar
Binary files differ
diff --git a/bin/tomcat-native.tar.gz b/bin/tomcat-native.tar.gz
index a764da7..2b47ef1 100644
--- a/bin/tomcat-native.tar.gz
+++ b/bin/tomcat-native.tar.gz
Binary files differ
diff --git a/bin/tool-wrapper.bat b/bin/tool-wrapper.bat
index 0d4dae6..331d42e 100644
--- a/bin/tool-wrapper.bat
+++ b/bin/tool-wrapper.bat
@@ -14,7 +14,6 @@
 rem See the License for the specific language governing permissions and

 rem limitations under the License.

 

-if "%OS%" == "Windows_NT" setlocal

 rem ---------------------------------------------------------------------------

 rem Wrapper script for command line tools

 rem

@@ -37,11 +36,12 @@
 rem                   containing some jars in order to allow replacement of APIs

 rem                   created outside of the JCP (i.e. DOM and SAX from W3C).

 rem                   It can also be used to update the XML parser implementation.

+rem                   Note that Java 9 no longer supports this feature.

 rem                   Defaults to $CATALINA_HOME/endorsed.

-rem

-rem $Id: tool-wrapper.bat 1138835 2011-06-23 11:27:57Z rjung $

 rem ---------------------------------------------------------------------------

 

+setlocal

+

 rem Guess CATALINA_HOME if not defined

 set "CURRENT_DIR=%cd%"

 if not "%CATALINA_HOME%" == "" goto gotHome

@@ -83,6 +83,19 @@
 

 set JAVA_OPTS=%JAVA_OPTS% -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager

 

+rem Java 9 no longer supports the java.endorsed.dirs

+rem system property. Only try to use it if

+rem JAVA_ENDORSED_DIRS was explicitly set

+rem or CATALINA_HOME/endorsed exists.

+set ENDORSED_PROP=ignore.endorsed.dirs

+if "%JAVA_ENDORSED_DIRS%" == "" goto noEndorsedVar

+set ENDORSED_PROP=java.endorsed.dirs

+goto doneEndorsed

+:noEndorsedVar

+if not exist "%CATALINA_HOME%\endorsed" goto doneEndorsed

+set ENDORSED_PROP=java.endorsed.dirs

+:doneEndorsed

+

 rem Get remaining unshifted command line arguments and save them in the

 set CMD_LINE_ARGS=

 :setArgs

@@ -92,6 +105,6 @@
 goto setArgs

 :doneSetArgs

 

-%_RUNJAVA% %JAVA_OPTS% %TOOL_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.home="%CATALINA_HOME%" org.apache.catalina.startup.Tool %CMD_LINE_ARGS%

+%_RUNJAVA% %JAVA_OPTS% %TOOL_OPTS% -D%ENDORSED_PROP%="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.home="%CATALINA_HOME%" org.apache.catalina.startup.Tool %CMD_LINE_ARGS%

 

 :end

diff --git a/bin/tool-wrapper.sh b/bin/tool-wrapper.sh
index 8979209..54ea0fc 100755
--- a/bin/tool-wrapper.sh
+++ b/bin/tool-wrapper.sh
@@ -37,9 +37,8 @@
 #                   containing some jars in order to allow replacement of APIs
 #                   created outside of the JCP (i.e. DOM and SAX from W3C).
 #                   It can also be used to update the XML parser implementation.
+#                   Note that Java 9 no longer supports this feature.
 #                   Defaults to $CATALINA_HOME/endorsed.
-#
-# $Id: tool-wrapper.sh 1138835 2011-06-23 11:27:57Z rjung $
 # -----------------------------------------------------------------------------
 
 # OS specific support.  $var _must_ be set to either true or false.
@@ -131,11 +130,24 @@
   JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"`
 fi
 
+# Java 9 no longer supports the java.endorsed.dirs
+# system property. Only try to use it if
+# JAVA_ENDORSED_DIRS was explicitly set
+# or CATALINA_HOME/endorsed exists.
+ENDORSED_PROP=ignore.endorsed.dirs
+if [ -n "$JAVA_ENDORSED_DIRS" ]; then
+    ENDORSED_PROP=java.endorsed.dirs
+fi
+if [ -d "$CATALINA_HOME/endorsed" ]; then
+    ENDORSED_PROP=java.endorsed.dirs
+fi
+
 JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
 
 # ----- Execute The Requested Command -----------------------------------------
 
 exec "$_RUNJAVA" $JAVA_OPTS $TOOL_OPTS \
-  -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
+  -D$ENDORSED_PROP="$JAVA_ENDORSED_DIRS" \
+  -classpath "$CLASSPATH" \
   -Dcatalina.home="$CATALINA_HOME" \
   org.apache.catalina.startup.Tool "$@"
diff --git a/bin/version.bat b/bin/version.bat
index 3a67165..d294f76 100644
--- a/bin/version.bat
+++ b/bin/version.bat
@@ -14,13 +14,12 @@
 rem See the License for the specific language governing permissions and

 rem limitations under the License.

 

-if "%OS%" == "Windows_NT" setlocal

 rem ---------------------------------------------------------------------------

 rem Version script for the CATALINA Server

-rem

-rem $Id: version.bat 895392 2010-01-03 14:02:31Z kkolinko $

 rem ---------------------------------------------------------------------------

 

+setlocal

+

 rem Guess CATALINA_HOME if not defined

 set "CURRENT_DIR=%cd%"

 if not "%CATALINA_HOME%" == "" goto gotHome

diff --git a/bin/version.sh b/bin/version.sh
index c664f75..1cb19bd 100755
--- a/bin/version.sh
+++ b/bin/version.sh
@@ -17,8 +17,6 @@
 
 # -----------------------------------------------------------------------------
 # Version Script for the CATALINA Server
-#
-# $Id: version.sh 1202062 2011-11-15 06:50:02Z mturk $
 # -----------------------------------------------------------------------------
 
 # Better OS/400 detection: see Bugzilla 31132