升级Tomcat版本 apache-tomcat-7.0.77
diff --git a/tomcat-cas/bin/bootstrap.jar b/tomcat-cas/bin/bootstrap.jar
index 4ab1bf5..4f9dad0 100644
--- a/tomcat-cas/bin/bootstrap.jar
+++ b/tomcat-cas/bin/bootstrap.jar
Binary files differ
diff --git a/tomcat-cas/bin/catalina-tasks.xml b/tomcat-cas/bin/catalina-tasks.xml
index 3554a2f..1ecb94f 100644
--- a/tomcat-cas/bin/catalina-tasks.xml
+++ b/tomcat-cas/bin/catalina-tasks.xml
@@ -25,32 +25,13 @@
   <!-- 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}/.."/>

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

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

     <classpath>

       <fileset file="${catalina.home}/bin/tomcat-juli.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"/>

-    </classpath>

-  </taskdef>

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

-    <classpath>

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

-    </classpath>

-  </taskdef>

-  <typedef

-        name="jmxEquals"

-        classname="org.apache.catalina.ant.jmx.JMXAccessorEqualsCondition">

-    <classpath>

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

+      <fileset dir="${catalina.home}/lib" includes="*.jar"/>

     </classpath>

   </typedef>

-  <typedef

-        name="jmxCondition"

-        classname="org.apache.catalina.ant.jmx.JMXAccessorCondition">

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

     <classpath>

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

     </classpath>

diff --git a/tomcat-cas/bin/catalina.bat b/tomcat-cas/bin/catalina.bat
index 122b085..859ca9b 100644
--- a/tomcat-cas/bin/catalina.bat
+++ b/tomcat-cas/bin/catalina.bat
@@ -14,12 +14,24 @@
 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

 rem Environment Variable Prerequisites

 rem

+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

@@ -27,7 +39,11 @@
 rem                   the same directory that CATALINA_HOME points to.

 rem

 rem   CATALINA_OPTS   (Optional) Java runtime options used when the "start",

-rem                   or "run" command is executed.

+rem                   "run" or "debug" command is executed.

+rem                   Include here and not in JAVA_OPTS all options, that should

+rem                   only be used by Tomcat itself, not by the stop process,

+rem                   the version command etc.

+rem                   Examples are heap size, GC logging, JMX ports etc.

 rem

 rem   CATALINA_TMPDIR (Optional) Directory path location of temporary directory

 rem                   the JVM should use (java.io.tmpdir).  Defaults to

@@ -37,14 +53,19 @@
 rem                   Required to run the with the "debug" argument.

 rem

 rem   JRE_HOME        Must point at your Java Runtime installation.

-rem                   Defaults to JAVA_HOME if empty.

+rem                   Defaults to JAVA_HOME if empty. If JRE_HOME and JAVA_HOME

+rem                   are both set, JRE_HOME is used.

 rem

-rem   JAVA_OPTS       (Optional) Java runtime options used when the "start",

-rem                   "stop", or "run" command is executed.

+rem   JAVA_OPTS       (Optional) Java runtime options used when any command

+rem                   is executed.

+rem                   Include here and not in CATALINA_OPTS all options, that

+rem                   should be used by Tomcat and also by the stop process,

+rem                   the version command etc.

+rem                   Most options should go into CATALINA_OPTS.

 rem

 rem   JAVA_ENDORSED_DIRS (Optional) Lists of of semi-colon separated directories

-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                   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                   Defaults to $CATALINA_HOME/endorsed.

 rem

@@ -66,11 +87,15 @@
 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"

 rem

-rem   LOGGING_MANAGER (Optional) Override Tomcat's logging manager 

+rem   LOGGING_MANAGER (Optional) Override Tomcat's logging manager

 rem                   Example (all one line)

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

 rem

@@ -80,6 +105,23 @@
 rem                   set TITLE=Tomcat.Cluster#1.Server#1 [%DATE% %TIME%]

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

 

+setlocal

+

+rem Suppress Terminate batch job on CTRL+C

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

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

+if exist "%TEMP%\%~nx0.run" goto mainEntry

+echo Y>"%TEMP%\%~nx0.run"

+if not exist "%TEMP%\%~nx0.run" goto mainEntry

+echo Y>"%TEMP%\%~nx0.Y"

+call "%~f0" %* <"%TEMP%\%~nx0.Y"

+rem Use provided errorlevel

+set RETVAL=%ERRORLEVEL%

+del /Q "%TEMP%\%~nx0.Y" >NUL 2>&1

+exit /B %RETVAL%

+:mainEntry

+del /Q "%TEMP%\%~nx0.run" >NUL 2>&1

+

 rem Guess CATALINA_HOME if not defined

 set "CURRENT_DIR=%cd%"

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

@@ -89,6 +131,7 @@
 set "CATALINA_HOME=%cd%"

 cd "%CURRENT_DIR%"

 :gotHome

+

 if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome

 echo The CATALINA_HOME environment variable is not defined correctly

 echo This environment variable is needed to run this program

@@ -118,40 +161,44 @@
 echo This file is needed to run this program

 goto end

 :okSetclasspath

-set "BASEDIR=%CATALINA_HOME%"

 call "%CATALINA_HOME%\bin\setclasspath.bat" %1

 if errorlevel 1 goto end

 

-if not "%CATALINA_TMPDIR%" == "" goto gotTmpdir

-set "CATALINA_TMPDIR=%CATALINA_BASE%\temp"

-:gotTmpdir

-

-rem Add tomcat-juli.jar and bootstrap.jar to classpath

-rem tomcat-juli.jar can be over-ridden per instance

+rem Add on extra jar file to CLASSPATH

 rem Note that there are no quotes as we do not want to introduce random

 rem quotes into the CLASSPATH

 if "%CLASSPATH%" == "" goto emptyClasspath

 set "CLASSPATH=%CLASSPATH%;"

 :emptyClasspath

-if "%CATALINA_BASE%" == "%CATALINA_HOME%" goto juliClasspathHome

+set "CLASSPATH=%CLASSPATH%%CATALINA_HOME%\bin\bootstrap.jar"

+

+if not "%CATALINA_TMPDIR%" == "" goto gotTmpdir

+set "CATALINA_TMPDIR=%CATALINA_BASE%\temp"

+:gotTmpdir

+

+rem Add tomcat-juli.jar to classpath

+rem tomcat-juli.jar can be over-ridden per instance

 if not exist "%CATALINA_BASE%\bin\tomcat-juli.jar" goto juliClasspathHome

-set "CLASSPATH=%CLASSPATH%%CATALINA_BASE%\bin\tomcat-juli.jar;%CATALINA_HOME%\bin\bootstrap.jar"

+set "CLASSPATH=%CLASSPATH%;%CATALINA_BASE%\bin\tomcat-juli.jar"

 goto juliClasspathDone

 :juliClasspathHome

-set "CLASSPATH=%CLASSPATH%%CATALINA_HOME%\bin\bootstrap.jar"

+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 ----- Execute The Requested Command ---------------------------------------

 

@@ -194,6 +241,7 @@
 if ""%1"" == ""run"" goto doRun

 if ""%1"" == ""start"" goto doStart

 if ""%1"" == ""stop"" goto doStop

+if ""%1"" == ""configtest"" goto doConfigTest

 if ""%1"" == ""version"" goto doVersion

 

 echo Usage:  catalina ( commands ... )

@@ -206,6 +254,7 @@
 echo   start             Start Catalina in a separate window

 echo   start -security   Start in a separate window with security manager

 echo   stop              Stop Catalina

+echo   configtest        Run a basic syntax check on server.xml

 echo   version           What version of tomcat are you running?

 goto end

 

@@ -229,13 +278,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

@@ -248,6 +292,12 @@
 set CATALINA_OPTS=

 goto execCmd

 

+:doConfigTest

+shift

+set ACTION=configtest

+set CATALINA_OPTS=

+goto execCmd

+

 :doVersion

 %_EXECJAVA% -classpath "%CATALINA_HOME%\lib\catalina.jar" org.apache.catalina.util.ServerInfo

 goto end

@@ -266,17 +316,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% -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%

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

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

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

 goto end

 

 :end

diff --git a/tomcat-cas/bin/catalina.sh b/tomcat-cas/bin/catalina.sh
index 45ac16d..33a4803 100644
--- a/tomcat-cas/bin/catalina.sh
+++ b/tomcat-cas/bin/catalina.sh
@@ -16,10 +16,13 @@
 # limitations under the License.
 
 # -----------------------------------------------------------------------------
-# Start/Stop Script for the CATALINA Server
+# Control Script for the CATALINA Server
 #
 # Environment Variable Prerequisites
 #
+#   Do not set the variables in this script. Instead put them into a script
+#   setenv.sh in CATALINA_BASE/bin to keep your customizations separate.
+#
 #   CATALINA_HOME   May point at your Catalina "build" directory.
 #
 #   CATALINA_BASE   (Optional) Base directory for resolving dynamic portions
@@ -31,7 +34,11 @@
 #                   Default is $CATALINA_BASE/logs/catalina.out
 #
 #   CATALINA_OPTS   (Optional) Java runtime options used when the "start",
-#                   or "run" command is executed.
+#                   "run" or "debug" command is executed.
+#                   Include here and not in JAVA_OPTS all options, that should
+#                   only be used by Tomcat itself, not by the stop process,
+#                   the version command etc.
+#                   Examples are heap size, GC logging, JMX ports etc.
 #
 #   CATALINA_TMPDIR (Optional) Directory path location of temporary directory
 #                   the JVM should use (java.io.tmpdir).  Defaults to
@@ -40,11 +47,16 @@
 #   JAVA_HOME       Must point at your Java Development Kit installation.
 #                   Required to run the with the "debug" argument.
 #
-#   JRE_HOME        Must point at your Java Development Kit installation.
-#                   Defaults to JAVA_HOME if empty.
+#   JRE_HOME        Must point at your Java Runtime installation.
+#                   Defaults to JAVA_HOME if empty. If JRE_HOME and JAVA_HOME
+#                   are both set, JRE_HOME is used.
 #
-#   JAVA_OPTS       (Optional) Java runtime options used when the "start",
-#                   "stop", or "run" command is executed.
+#   JAVA_OPTS       (Optional) Java runtime options used when any command
+#                   is executed.
+#                   Include here and not in CATALINA_OPTS all options, that
+#                   should be used by Tomcat and also by the stop process,
+#                   the version command etc.
+#                   Most options should go into CATALINA_OPTS.
 #
 #   JAVA_ENDORSED_DIRS (Optional) Lists of of colon separated directories
 #                   containing some jars in order to allow replacement of APIs
@@ -70,8 +82,13 @@
 #                   -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 catalina startup java process, when start (fork) is used
+#                   of the catalina startup java process, when start (fork) is
+#                   used
 #
 #   LOGGING_CONFIG  (Optional) Override Tomcat's logging config file
 #                   Example (all one line)
@@ -80,16 +97,23 @@
 #   LOGGING_MANAGER (Optional) Override Tomcat's logging manager
 #                   Example (all one line)
 #                   LOGGING_MANAGER="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
+#
+#   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
-os400=false
 darwin=false
+os400=false
+hpux=false
 case "`uname`" in
 CYGWIN*) cygwin=true;;
-OS400*) os400=true;;
 Darwin*) darwin=true;;
+OS400*) os400=true;;
+HP-UX*) hpux=true;;
 esac
 
 # resolve links - $0 may be a softlink
@@ -151,11 +175,9 @@
   # 1. owned by the user
   # 2. owned by the PRIMARY group of the user
   # this will not work if the user belongs in secondary groups
-  BASEDIR="$CATALINA_HOME"
   . "$CATALINA_HOME"/bin/setclasspath.sh
 else
   if [ -r "$CATALINA_HOME"/bin/setclasspath.sh ]; then
-    BASEDIR="$CATALINA_HOME"
     . "$CATALINA_HOME"/bin/setclasspath.sh
   else
     echo "Cannot find $CATALINA_HOME/bin/setclasspath.sh"
@@ -164,20 +186,11 @@
   fi
 fi
 
-if [ -z "$CATALINA_BASE" ] ; then
-  CATALINA_BASE="$CATALINA_HOME"
-fi
-
-# Add tomcat-juli.jar and bootstrap.jar to classpath
-# tomcat-juli.jar can be over-ridden per instance
+# Add on extra jar files to CLASSPATH
 if [ ! -z "$CLASSPATH" ] ; then
   CLASSPATH="$CLASSPATH":
 fi
-if [ "$CATALINA_BASE" != "$CATALINA_HOME" ] && [ -r "$CATALINA_BASE/bin/tomcat-juli.jar" ] ; then
-  CLASSPATH="$CLASSPATH""$CATALINA_BASE"/bin/tomcat-juli.jar:"$CATALINA_HOME"/bin/bootstrap.jar
-else
-  CLASSPATH="$CLASSPATH""$CATALINA_HOME"/bin/bootstrap.jar
-fi
+CLASSPATH="$CLASSPATH""$CATALINA_HOME"/bin/bootstrap.jar
 
 if [ -z "$CATALINA_OUT" ] ; then
   CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out
@@ -188,6 +201,14 @@
   CATALINA_TMPDIR="$CATALINA_BASE"/temp
 fi
 
+# Add tomcat-juli.jar to classpath
+# tomcat-juli.jar can be over-ridden per instance
+if [ -r "$CATALINA_BASE/bin/tomcat-juli.jar" ] ; then
+  CLASSPATH=$CLASSPATH:$CATALINA_BASE/bin/tomcat-juli.jar
+else
+  CLASSPATH=$CLASSPATH:$CATALINA_HOME/bin/tomcat-juli.jar
+fi
+
 # Bugzilla 37848: When no TTY is available, don't output to console
 have_tty=0
 if [ "`tty`" != "not a tty" ]; then
@@ -205,6 +226,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
@@ -219,6 +245,22 @@
   LOGGING_MANAGER="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
 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
+
 # ----- Execute The Requested Command -----------------------------------------
 
 # Bugzilla 37848: only output this if we have a TTY
@@ -250,7 +292,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
 
@@ -293,20 +335,20 @@
       echo "Using Security Manager"
     fi
     shift
-    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 \
+      -Djava.endorsed.dirs="\"$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
-    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 \
+      -Djava.endorsed.dirs="\"$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
 
@@ -321,6 +363,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."
@@ -357,24 +401,24 @@
       echo "Using Security Manager"
     fi
     shift
-    "$_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 \
+      -Djava.endorsed.dirs="\"$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 &
+      >> "$CATALINA_OUT" 2>&1 "&"
 
   else
-    "$_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 \
+      -Djava.endorsed.dirs="\"$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 &
+      >> "$CATALINA_OUT" 2>&1 "&"
 
   fi
 
@@ -382,6 +426,8 @@
     echo $! > "$CATALINA_PID"
   fi
 
+  echo "Tomcat started."
+
 elif [ "$1" = "stop" ] ; then
 
   shift
@@ -417,14 +463,22 @@
       exit 1
     fi
   fi
-  
-  "$_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 \
+    -Djava.endorsed.dirs="\"$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
@@ -434,25 +488,32 @@
           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
     fi
   fi
 
+  KILL_SLEEP_INTERVAL=5
   if [ $FORCE -eq 1 ]; then
     if [ -z "$CATALINA_PID" ]; then
       echo "Kill failed: \$CATALINA_PID not set"
@@ -461,14 +522,46 @@
         PID=`cat "$CATALINA_PID"`
         echo "Killing Tomcat with the PID: $PID"
         kill -9 $PID
-        rm -f "$CATALINA_PID" >/dev/null 2>&1
-        if [ $? != 0 ]; then
-          echo "Tomcat was killed but the PID file could not be removed."
+        while [ $KILL_SLEEP_INTERVAL -ge 0 ]; do
+            kill -0 `cat "$CATALINA_PID"` >/dev/null 2>&1
+            if [ $? -gt 0 ]; then
+                rm -f "$CATALINA_PID" >/dev/null 2>&1
+                if [ $? != 0 ]; then
+                    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
+                sleep 1
+            fi
+            KILL_SLEEP_INTERVAL=`expr $KILL_SLEEP_INTERVAL - 1 `
+        done
+        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
     fi
   fi
 
+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\"" \
+      org.apache.catalina.startup.Bootstrap configtest
+    result=$?
+    if [ $result -ne 0 ]; then
+        echo "Configuration error detected!"
+    fi
+    exit $result
+
 elif [ "$1" = "version" ] ; then
 
     "$_RUNJAVA"   \
@@ -495,6 +588,7 @@
   echo "  stop n            Stop Catalina, waiting up to n seconds for the process to end"
   echo "  stop -force       Stop Catalina, wait up to 5 seconds and then use kill -KILL if still running"
   echo "  stop n -force     Stop Catalina, wait up to n seconds and then use kill -KILL if still running"
+  echo "  configtest        Run a basic syntax check on server.xml - check exit code for result"
   echo "  version           What version of tomcat are you running?"
   echo "Note: Waiting for the process to end and use of the -force option require that \$CATALINA_PID is defined"
   exit 1
diff --git a/tomcat-cas/bin/configtest.bat b/tomcat-cas/bin/configtest.bat
new file mode 100644
index 0000000..02448e1
--- /dev/null
+++ b/tomcat-cas/bin/configtest.bat
@@ -0,0 +1,58 @@
+@echo off

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

+rem contributor license agreements.  See the NOTICE file distributed with

+rem this work for additional information regarding copyright ownership.

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

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

+rem the License.  You may obtain a copy of the License at

+rem

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

+rem

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

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

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

+rem See the License for the specific language governing permissions and

+rem limitations under the License.

+

+rem ---------------------------------------------------------------------------

+rem Configuration test script for the CATALINA Server

+rem ---------------------------------------------------------------------------

+

+setlocal

+

+rem Guess CATALINA_HOME if not defined

+set "CURRENT_DIR=%cd%"

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

+set "CATALINA_HOME=%CURRENT_DIR%"

+if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome

+cd ..

+set "CATALINA_HOME=%cd%"

+cd "%CURRENT_DIR%"

+:gotHome

+if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome

+echo The CATALINA_HOME environment variable is not defined correctly

+echo This environment variable is needed to run this program

+goto end

+:okHome

+

+set "EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat"

+

+rem Check that target executable exists

+if exist "%EXECUTABLE%" goto okExec

+echo Cannot find "%EXECUTABLE%"

+echo This file is needed to run this program

+goto end

+:okExec

+

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

+set CMD_LINE_ARGS=

+:setArgs

+if ""%1""=="""" goto doneSetArgs

+set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1

+shift

+goto setArgs

+:doneSetArgs

+

+call "%EXECUTABLE%" configtest %CMD_LINE_ARGS%

+

+:end

diff --git a/tomcat-cas/bin/configtest.sh b/tomcat-cas/bin/configtest.sh
new file mode 100644
index 0000000..9a8ebff
--- /dev/null
+++ b/tomcat-cas/bin/configtest.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+# 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.
+
+# -----------------------------------------------------------------------------
+# Configuration Test Script for the CATALINA Server
+# -----------------------------------------------------------------------------
+
+# Better OS/400 detection: see Bugzilla 31132
+os400=false
+case "`uname`" in
+OS400*) os400=true;;
+esac
+
+# resolve links - $0 may be a softlink
+PRG="$0"
+
+while [ -h "$PRG" ] ; do
+  ls=`ls -ld "$PRG"`
+  link=`expr "$ls" : '.*-> \(.*\)$'`
+  if expr "$link" : '/.*' > /dev/null; then
+    PRG="$link"
+  else
+    PRG=`dirname "$PRG"`/"$link"
+  fi
+done
+
+PRGDIR=`dirname "$PRG"`
+EXECUTABLE=catalina.sh
+
+# Check that target executable exists
+if $os400; then
+  # -x will Only work on the os400 if the files are:
+  # 1. owned by the user
+  # 2. owned by the PRIMARY group of the user
+  # this will not work if the user belongs in secondary groups
+  eval
+else
+  if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
+    echo "Cannot find $PRGDIR/$EXECUTABLE"
+    echo "The file is absent or does not have execute permission"
+    echo "This file is needed to run this program"
+    exit 1
+  fi
+fi
+
+exec "$PRGDIR"/"$EXECUTABLE" configtest "$@"
diff --git a/tomcat-cas/bin/cpappend.bat b/tomcat-cas/bin/cpappend.bat
deleted file mode 100644
index 455e832..0000000
--- a/tomcat-cas/bin/cpappend.bat
+++ /dev/null
@@ -1,33 +0,0 @@
-@echo off

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

-rem contributor license agreements.  See the NOTICE file distributed with

-rem this work for additional information regarding copyright ownership.

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

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

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

-rem

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

-rem

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

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

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

-rem See the License for the specific language governing permissions and

-rem limitations under the License.

-

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

-rem Append to CLASSPATH

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

-

-rem Process the first argument

-if ""%1"" == """" goto end

-set CLASSPATH=%CLASSPATH%;%1

-shift

-

-rem Process the remaining arguments

-:setArgs

-if ""%1"" == """" goto doneSetArgs

-set CLASSPATH=%CLASSPATH% %1

-shift

-goto setArgs

-:doneSetArgs

-:end

diff --git a/tomcat-cas/bin/daemon.sh b/tomcat-cas/bin/daemon.sh
index fc18f76..dee6c77 100644
--- a/tomcat-cas/bin/daemon.sh
+++ b/tomcat-cas/bin/daemon.sh
@@ -104,7 +104,13 @@
 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
 
@@ -119,17 +125,19 @@
 fi
 
 # Add on extra jar files to CLASSPATH
-# tomcat-juli.jar can be over-ridden per instance
 test ".$CLASSPATH" != . && CLASSPATH="${CLASSPATH}:"
-if [ "$CATALINA_BASE" != "$CATALINA_HOME" ] && [ -r "$CATALINA_BASE/bin/tomcat-juli.jar" ] ; then
-  CLASSPATH="$CLASSPATH$CATALINA_BASE/bin/tomcat-juli.jar:$CATALINA_HOME/bin/commons-daemon.jar:$CATALINA_HOME/bin/bootstrap.jar"
-else
-  CLASSPATH="$CLASSPATH$CATALINA_HOME/bin/commons-daemon.jar:$CATALINA_HOME/bin/bootstrap.jar"
-fi
+CLASSPATH="$CLASSPATH$CATALINA_HOME/bin/bootstrap.jar:$CATALINA_HOME/bin/commons-daemon.jar"
 
 test ".$CATALINA_OUT" = . && CATALINA_OUT="$CATALINA_BASE/logs/catalina-daemon.out"
 test ".$CATALINA_TMP" = . && CATALINA_TMP="$CATALINA_BASE/temp"
 
+# Add tomcat-juli.jar to classpath
+# tomcat-juli.jar can be over-ridden per instance
+if [ -r "$CATALINA_BASE/bin/tomcat-juli.jar" ] ; then
+  CLASSPATH="$CLASSPATH:$CATALINA_BASE/bin/tomcat-juli.jar"
+else
+  CLASSPATH="$CLASSPATH:$CATALINA_HOME/bin/tomcat-juli.jar"
+fi
 # 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
diff --git a/tomcat-cas/bin/digest.bat b/tomcat-cas/bin/digest.bat
index fbc36d3..428b9d1 100644
--- a/tomcat-cas/bin/digest.bat
+++ b/tomcat-cas/bin/digest.bat
@@ -14,16 +14,20 @@
 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 ---------------------------------------------------------------------------

 

+setlocal

+

 rem Guess CATALINA_HOME if not defined

+set "CURRENT_DIR=%cd%"

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

-set CATALINA_HOME=.

+set "CATALINA_HOME=%CURRENT_DIR%"

 if exist "%CATALINA_HOME%\bin\tool-wrapper.bat" goto okHome

-set CATALINA_HOME=..

+cd ..

+set "CATALINA_HOME=%cd%"

+cd "%CURRENT_DIR%"

 :gotHome

 if exist "%CATALINA_HOME%\bin\tool-wrapper.bat" goto okHome

 echo The CATALINA_HOME environment variable is not defined correctly

diff --git a/tomcat-cas/bin/digest.sh b/tomcat-cas/bin/digest.sh
index 1b5d5e7..62ed5d0 100644
--- a/tomcat-cas/bin/digest.sh
+++ b/tomcat-cas/bin/digest.sh
@@ -19,6 +19,12 @@
 # Script to digest password using the algorithm specified
 # -----------------------------------------------------------------------------
 
+# Better OS/400 detection: see Bugzilla 31132
+os400=false
+case "`uname`" in
+OS400*) os400=true;;
+esac
+
 # resolve links - $0 may be a softlink
 PRG="$0"
 
@@ -31,16 +37,24 @@
     PRG=`dirname "$PRG"`/"$link"
   fi
 done
- 
+
 PRGDIR=`dirname "$PRG"`
 EXECUTABLE=tool-wrapper.sh
 
 # Check that target executable exists
-if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
-  echo "Cannot find $PRGDIR/$EXECUTABLE"
-  echo "The file is absent or does not have execute permission"
-  echo "This file is needed to run this program"
-  exit 1
+if $os400; then
+  # -x will Only work on the os400 if the files are:
+  # 1. owned by the user
+  # 2. owned by the PRIMARY group of the user
+  # this will not work if the user belongs in secondary groups
+  eval
+else
+  if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
+    echo "Cannot find $PRGDIR/$EXECUTABLE"
+    echo "The file is absent or does not have execute permission"
+    echo "This file is needed to run this program"
+    exit 1
+  fi
 fi
 
 exec "$PRGDIR"/"$EXECUTABLE" -server org.apache.catalina.realm.RealmBase "$@"
diff --git a/tomcat-cas/bin/setclasspath.bat b/tomcat-cas/bin/setclasspath.bat
index 360b9e4..da0d8a3 100644
--- a/tomcat-cas/bin/setclasspath.bat
+++ b/tomcat-cas/bin/setclasspath.bat
@@ -15,61 +15,74 @@
 rem limitations under the License.

 

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

-rem Set CLASSPATH and Java options

+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 Make sure prerequisite environment variables are set

-if not "%JAVA_HOME%" == "" goto gotJdkHome

+

+rem In debug mode we need a real JDK (JAVA_HOME)

+if ""%1"" == ""debug"" goto needJavaHome

+

+rem Otherwise either JRE or JDK are fine

 if not "%JRE_HOME%" == "" goto gotJreHome

+if not "%JAVA_HOME%" == "" goto gotJavaHome

 echo Neither the JAVA_HOME nor the JRE_HOME environment variable is defined

 echo At least one of these environment variable is needed to run this program

 goto exit

 

-:gotJreHome

-if not exist "%JRE_HOME%\bin\java.exe" goto noJavaHome

-if not exist "%JRE_HOME%\bin\javaw.exe" goto noJavaHome

-if not ""%1"" == ""debug"" goto okJavaHome

-echo JAVA_HOME should point to a JDK in order to run in debug mode.

-goto exit

-

-:gotJdkHome

+:needJavaHome

+rem Check if we have a usable JDK

+if "%JAVA_HOME%" == "" goto noJavaHome

 if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome

 if not exist "%JAVA_HOME%\bin\javaw.exe" goto noJavaHome

 if not exist "%JAVA_HOME%\bin\jdb.exe" goto noJavaHome

 if not exist "%JAVA_HOME%\bin\javac.exe" goto noJavaHome

-if not "%JRE_HOME%" == "" goto okJavaHome

 set "JRE_HOME=%JAVA_HOME%"

-goto okJavaHome

+goto okJava

 

 :noJavaHome

-echo The JAVA_HOME environment variable is not defined correctly

-echo This environment variable is needed to run this program

-echo NB: JAVA_HOME should point to a JDK not a JRE

+echo The JAVA_HOME environment variable is not defined correctly.

+echo It is needed to run this program in debug mode.

+echo NB: JAVA_HOME should point to a JDK not a JRE.

 goto exit

-:okJavaHome

 

-if not "%BASEDIR%" == "" goto gotBasedir

-echo The BASEDIR environment variable is not defined

-echo This environment variable is needed to run this program

-goto exit

-:gotBasedir

-if exist "%BASEDIR%\bin\setclasspath.bat" goto okBasedir

-echo The BASEDIR environment variable is not defined correctly

-echo This environment variable is needed to run this program

-goto exit

-:okBasedir

+:gotJavaHome

+rem No JRE given, use JAVA_HOME as JRE_HOME

+set "JRE_HOME=%JAVA_HOME%"

 

+:gotJreHome

+rem Check if we have a usable JRE

+if not exist "%JRE_HOME%\bin\java.exe" goto noJreHome

+if not exist "%JRE_HOME%\bin\javaw.exe" goto noJreHome

+goto okJava

+

+:noJreHome

+rem Needed at least a JRE

+echo The JRE_HOME environment variable is not defined correctly

+echo This environment variable is needed to run this program

+goto exit

+

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

-set "JAVA_ENDORSED_DIRS=%BASEDIR%\endorsed"

+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/tomcat-cas/bin/setclasspath.sh b/tomcat-cas/bin/setclasspath.sh
index 590fd6e..873fad3 100644
--- a/tomcat-cas/bin/setclasspath.sh
+++ b/tomcat-cas/bin/setclasspath.sh
@@ -16,7 +16,9 @@
 # limitations under the License.
 
 # -----------------------------------------------------------------------------
-#  Set CLASSPATH and Java options
+#  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.
 # -----------------------------------------------------------------------------
 
 # Make sure prerequisite environment variables are set
@@ -74,44 +76,19 @@
     fi
   fi
 fi
-if [ -z "$BASEDIR" ]; then
-  echo "The BASEDIR environment variable is not defined"
-  echo "This environment variable is needed to run this program"
-  exit 1
-fi
-if [ ! -x "$BASEDIR"/bin/setclasspath.sh ]; then
-  if $os400; then
-    # -x will Only work on the os400 if the files are:
-    # 1. owned by the user
-    # 2. owned by the PRIMARY group of the user
-    # this will not work if the user belongs in secondary groups
-    eval
-  else
-    echo "The BASEDIR environment variable is not defined correctly"
-    echo "This environment variable is needed to run this program"
-    exit 1
-  fi
-fi
 
 # 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="$BASEDIR"/endorsed
+  JAVA_ENDORSED_DIRS="$CATALINA_HOME"/endorsed
 fi
 
-# OSX hack to CLASSPATH
-JIKESPATH=
-if [ `uname -s` = "Darwin" ]; then
-  OSXHACK="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Classes"
-  if [ -d "$OSXHACK" ]; then
-    for i in "$OSXHACK"/*.jar; do
-      JIKESPATH="$JIKESPATH":"$i"
-    done
-  fi
+# Set standard commands for invoking Java, if not already set.
+if [ -z "$_RUNJAVA" ]; then
+  _RUNJAVA="$JRE_HOME"/bin/java
 fi
-
-# Set standard commands for invoking Java.
-_RUNJAVA="$JRE_HOME"/bin/java
 if [ "$os400" != "true" ]; then
-  _RUNJDB="$JAVA_HOME"/bin/jdb
-fi
+  if [ -z "$_RUNJDB" ]; then
+    _RUNJDB="$JAVA_HOME"/bin/jdb
+  fi
+fi
\ No newline at end of file
diff --git a/tomcat-cas/bin/shutdown.bat b/tomcat-cas/bin/shutdown.bat
index d4a0335..119fb99 100644
--- a/tomcat-cas/bin/shutdown.bat
+++ b/tomcat-cas/bin/shutdown.bat
@@ -14,11 +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 ---------------------------------------------------------------------------

 

+setlocal

+

 rem Guess CATALINA_HOME if not defined

 set "CURRENT_DIR=%cd%"

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

diff --git a/tomcat-cas/bin/shutdown.sh b/tomcat-cas/bin/shutdown.sh
index e454500..cd0c97d 100644
--- a/tomcat-cas/bin/shutdown.sh
+++ b/tomcat-cas/bin/shutdown.sh
@@ -19,6 +19,12 @@
 # Stop script for the CATALINA Server
 # -----------------------------------------------------------------------------
 
+# Better OS/400 detection: see Bugzilla 31132
+os400=false
+case "`uname`" in
+OS400*) os400=true;;
+esac
+
 # resolve links - $0 may be a softlink
 PRG="$0"
 
@@ -31,16 +37,24 @@
     PRG=`dirname "$PRG"`/"$link"
   fi
 done
- 
+
 PRGDIR=`dirname "$PRG"`
 EXECUTABLE=catalina.sh
 
 # Check that target executable exists
-if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
-  echo "Cannot find $PRGDIR/$EXECUTABLE"
-  echo "The file is absent or does not have execute permission"
-  echo "This file is needed to run this program"
-  exit 1
+if $os400; then
+  # -x will Only work on the os400 if the files are:
+  # 1. owned by the user
+  # 2. owned by the PRIMARY group of the user
+  # this will not work if the user belongs in secondary groups
+  eval
+else
+  if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
+    echo "Cannot find $PRGDIR/$EXECUTABLE"
+    echo "The file is absent or does not have execute permission"
+    echo "This file is needed to run this program"
+    exit 1
+  fi
 fi
 
 exec "$PRGDIR"/"$EXECUTABLE" stop "$@"
diff --git a/tomcat-cas/bin/startup.bat b/tomcat-cas/bin/startup.bat
index 179e245..e9f46b8 100644
--- a/tomcat-cas/bin/startup.bat
+++ b/tomcat-cas/bin/startup.bat
@@ -14,11 +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 ---------------------------------------------------------------------------

 

+setlocal

+

 rem Guess CATALINA_HOME if not defined

 set "CURRENT_DIR=%cd%"

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

diff --git a/tomcat-cas/bin/startup.sh b/tomcat-cas/bin/startup.sh
index 3a68fe8..7b10287 100644
--- a/tomcat-cas/bin/startup.sh
+++ b/tomcat-cas/bin/startup.sh
@@ -21,11 +21,8 @@
 
 # Better OS/400 detection: see Bugzilla 31132
 os400=false
-darwin=false
 case "`uname`" in
-CYGWIN*) cygwin=true;;
 OS400*) os400=true;;
-Darwin*) darwin=true;;
 esac
 
 # resolve links - $0 may be a softlink
@@ -40,13 +37,13 @@
     PRG=`dirname "$PRG"`/"$link"
   fi
 done
- 
+
 PRGDIR=`dirname "$PRG"`
 EXECUTABLE=catalina.sh
 
 # Check that target executable exists
 if $os400; then
-  # -x will Only work on the os400 if the files are: 
+  # -x will Only work on the os400 if the files are:
   # 1. owned by the user
   # 2. owned by the PRIMARY group of the user
   # this will not work if the user belongs in secondary groups
@@ -58,6 +55,6 @@
     echo "This file is needed to run this program"
     exit 1
   fi
-fi 
+fi
 
 exec "$PRGDIR"/"$EXECUTABLE" start "$@"
diff --git a/tomcat-cas/bin/tomcat-juli.jar b/tomcat-cas/bin/tomcat-juli.jar
index ff13de8..51e0c19 100644
--- a/tomcat-cas/bin/tomcat-juli.jar
+++ b/tomcat-cas/bin/tomcat-juli.jar
Binary files differ
diff --git a/tomcat-cas/bin/tomcat-native.tar.gz b/tomcat-cas/bin/tomcat-native.tar.gz
index d2ab7dc..0f2e787 100644
--- a/tomcat-cas/bin/tomcat-native.tar.gz
+++ b/tomcat-cas/bin/tomcat-native.tar.gz
Binary files differ
diff --git a/tomcat-cas/bin/tool-wrapper.bat b/tomcat-cas/bin/tool-wrapper.bat
index 7b88835..fcff6da 100644
--- a/tomcat-cas/bin/tool-wrapper.bat
+++ b/tomcat-cas/bin/tool-wrapper.bat
@@ -14,28 +14,41 @@
 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

 rem Environment Variable Prerequisites

 rem

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

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

 rem

-rem   TOOL_OPTS     (Optional) Java runtime options used when the "start",

-rem                 "stop", or "run" command is executed.

+rem   TOOL_OPTS       (Optional) Java runtime options.

 rem

-rem   JAVA_HOME     Must point at your Java Development Kit installation.

+rem   JAVA_HOME       Must point at your Java Development Kit installation.

+rem                   Using JRE_HOME instead works as well.

 rem

-rem   JAVA_OPTS     (Optional) Java runtime options used when the "start",

-rem                 "stop", or "run" command is executed.

+rem   JRE_HOME        Must point at your Java Runtime installation.

+rem                   Defaults to JAVA_HOME if empty. If JRE_HOME and JAVA_HOME

+rem                   are both set, JRE_HOME is used.

+rem

+rem   JAVA_OPTS       (Optional) Java runtime options.

+rem

+rem   JAVA_ENDORSED_DIRS (Optional) Lists of of semi-colon separated directories

+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                   Defaults to $CATALINA_HOME/endorsed.

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

 

+setlocal

+

 rem Guess CATALINA_HOME if not defined

+set "CURRENT_DIR=%cd%"

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

-set CATALINA_HOME=.

+set "CATALINA_HOME=%CURRENT_DIR%"

 if exist "%CATALINA_HOME%\bin\tool-wrapper.bat" goto okHome

-set CATALINA_HOME=..

+cd ..

+set "CATALINA_HOME=%cd%"

+cd "%CURRENT_DIR%"

 :gotHome

 if exist "%CATALINA_HOME%\bin\tool-wrapper.bat" goto okHome

 echo The CATALINA_HOME environment variable is not defined correctly

@@ -56,18 +69,18 @@
 echo This file is needed to run this program

 goto end

 :okSetclasspath

-set "BASEDIR=%CATALINA_HOME%"

-call "%CATALINA_HOME%\bin\setclasspath.bat"

+call "%CATALINA_HOME%\bin\setclasspath.bat" %1

+if errorlevel 1 goto end

 

 rem Add on extra jar files to CLASSPATH

 rem Note that there are no quotes as we do not want to introduce random

 rem quotes into the CLASSPATH

-if "%CLASSPATH%" == "" goto noclasspath

-set "CLASSPATH=%CLASSPATH%;%CATALINA_HOME%\bin\bootstrap.jar;%BASEDIR%\lib\servlet-api.jar"

-goto okclasspath

-:noclasspath

-set "CLASSPATH=%CATALINA_HOME%\bin\bootstrap.jar;%BASEDIR%\lib\servlet-api.jar"

-:okclasspath

+if "%CLASSPATH%" == "" goto emptyClasspath

+set "CLASSPATH=%CLASSPATH%;"

+:emptyClasspath

+set "CLASSPATH=%CLASSPATH%%CATALINA_HOME%\bin\bootstrap.jar;%CATALINA_HOME%\bin\tomcat-juli.jar;%CATALINA_HOME%\lib\servlet-api.jar"

+

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

 

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

 set CMD_LINE_ARGS=

diff --git a/tomcat-cas/bin/tool-wrapper.sh b/tomcat-cas/bin/tool-wrapper.sh
index 71c1de4..31cebf6 100644
--- a/tomcat-cas/bin/tool-wrapper.sh
+++ b/tomcat-cas/bin/tool-wrapper.sh
@@ -20,21 +20,34 @@
 #
 # Environment Variable Prerequisites
 #
-#   CATALINA_HOME May point at your Catalina "build" directory.
+#   CATALINA_HOME   May point at your Catalina "build" directory.
 #
-#   TOOL_OPTS     (Optional) Java runtime options used when the "start",
-#                 "stop", or "run" command is executed.
+#   TOOL_OPTS       (Optional) Java runtime options.
 #
-#   JAVA_HOME     Must point at your Java Development Kit installation.
+#   JAVA_HOME       Must point at your Java Development Kit installation.
+#                   Using JRE_HOME instead works as well.
 #
-#   JAVA_OPTS     (Optional) Java runtime options used when the "start",
-#                 "stop", or "run" command is executed.
+#   JRE_HOME        Must point at your Java Runtime installation.
+#                   Defaults to JAVA_HOME if empty. If JRE_HOME and JAVA_HOME
+#                   are both set, JRE_HOME is used.
+#
+#   JAVA_OPTS       (Optional) Java runtime options.
+#
+#   JAVA_ENDORSED_DIRS (Optional) Lists of of colon separated directories
+#                   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.
+#                   Defaults to $CATALINA_HOME/endorsed.
 # -----------------------------------------------------------------------------
 
 # OS specific support.  $var _must_ be set to either true or false.
 cygwin=false
+darwin=false
+os400=false
 case "`uname`" in
 CYGWIN*) cygwin=true;;
+Darwin*) darwin=true;;
+OS400*) os400=true;;
 esac
 
 # resolve links - $0 may be a softlink
@@ -52,43 +65,72 @@
 
 # Get standard environment variables
 PRGDIR=`dirname "$PRG"`
-CATALINA_HOME=`cd "$PRGDIR/.." >/dev/null; pwd`
+
+# Only set CATALINA_HOME if not already set
+[ -z "$CATALINA_HOME" ] && CATALINA_HOME=`cd "$PRGDIR/.." >/dev/null; pwd`
 
 # 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.
 CLASSPATH=
 
-if [ -r "$CATALINA_HOME"/bin/setenv.sh ]; then
-  . "$CATALINA_HOME"/bin/setenv.sh
+if [ -r "$CATALINA_HOME/bin/setenv.sh" ]; then
+  . "$CATALINA_HOME/bin/setenv.sh"
 fi
 
 # For Cygwin, ensure paths are in UNIX format before anything is touched
 if $cygwin; then
   [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+  [ -n "$JRE_HOME" ] && JRE_HOME=`cygpath --unix "$JRE_HOME"`
   [ -n "$CATALINA_HOME" ] && CATALINA_HOME=`cygpath --unix "$CATALINA_HOME"`
   [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
 fi
 
+# For OS400
+if $os400; then
+  # Set job priority to standard for interactive (interactive - 6) by using
+  # the interactive priority - 6, the helper threads that respond to requests
+  # will be running at the same priority as interactive jobs.
+  COMMAND='chgjob job('$JOBNAME') runpty(6)'
+  system $COMMAND
+
+  # Enable multi threading
+  export QIBM_MULTI_THREADED=Y
+fi
+
 # Get standard Java environment variables
-if [ -r "$CATALINA_HOME"/bin/setclasspath.sh ]; then
-  BASEDIR="$CATALINA_HOME"
+if $os400; then
+  # -r will Only work on the os400 if the files are:
+  # 1. owned by the user
+  # 2. owned by the PRIMARY group of the user
+  # this will not work if the user belongs in secondary groups
   . "$CATALINA_HOME"/bin/setclasspath.sh
 else
-  echo "Cannot find $CATALINA_HOME/bin/setclasspath.sh"
-  echo "This file is needed to run this program"
-  exit 1
+  if [ -r "$CATALINA_HOME"/bin/setclasspath.sh ]; then
+    . "$CATALINA_HOME"/bin/setclasspath.sh
+  else
+    echo "Cannot find $CATALINA_HOME/bin/setclasspath.sh"
+    echo "This file is needed to run this program"
+    exit 1
+  fi
 fi
 
 # Add on extra jar files to CLASSPATH
-CLASSPATH="$CLASSPATH":"$CATALINA_HOME"/bin/bootstrap.jar:"$BASEDIR"/lib/servlet-api.jar
+if [ ! -z "$CLASSPATH" ] ; then
+  CLASSPATH="$CLASSPATH":
+fi
+CLASSPATH="$CLASSPATH""$CATALINA_HOME"/bin/bootstrap.jar:"$CATALINA_HOME"/bin/tomcat-juli.jar:"$CATALINA_HOME"/lib/servlet-api.jar
 
 # For Cygwin, switch paths to Windows format before running java
 if $cygwin; then
-  JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
-  CATALINA_HOME=`cygpath --path --windows "$CATALINA_HOME"`
+  JAVA_HOME=`cygpath --absolute --windows "$JAVA_HOME"`
+  JRE_HOME=`cygpath --absolute --windows "$JRE_HOME"`
+  CATALINA_HOME=`cygpath --absolute --windows "$CATALINA_HOME"`
   CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
+  JAVA_ENDORSED_DIRS=`cygpath --path --windows "$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 \
diff --git a/tomcat-cas/bin/version.bat b/tomcat-cas/bin/version.bat
index e190c23..d294f76 100644
--- a/tomcat-cas/bin/version.bat
+++ b/tomcat-cas/bin/version.bat
@@ -14,11 +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 ---------------------------------------------------------------------------

 

+setlocal

+

 rem Guess CATALINA_HOME if not defined

 set "CURRENT_DIR=%cd%"

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

diff --git a/tomcat-cas/bin/version.sh b/tomcat-cas/bin/version.sh
index 6723161..1cb19bd 100644
--- a/tomcat-cas/bin/version.sh
+++ b/tomcat-cas/bin/version.sh
@@ -19,6 +19,12 @@
 # Version Script for the CATALINA Server
 # -----------------------------------------------------------------------------
 
+# Better OS/400 detection: see Bugzilla 31132
+os400=false
+case "`uname`" in
+OS400*) os400=true;;
+esac
+
 # resolve links - $0 may be a softlink
 PRG="$0"
 
@@ -36,11 +42,19 @@
 EXECUTABLE=catalina.sh
 
 # Check that target executable exists
-if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
-  echo "Cannot find $PRGDIR/$EXECUTABLE"
-  echo "The file is absent or does not have execute permission"
-  echo "This file is needed to run this program"
-  exit 1
+if $os400; then
+  # -x will Only work on the os400 if the files are:
+  # 1. owned by the user
+  # 2. owned by the PRIMARY group of the user
+  # this will not work if the user belongs in secondary groups
+  eval
+else
+  if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
+    echo "Cannot find $PRGDIR/$EXECUTABLE"
+    echo "The file is absent or does not have execute permission"
+    echo "This file is needed to run this program"
+    exit 1
+  fi
 fi
 
 exec "$PRGDIR"/"$EXECUTABLE" version "$@"