From ca728254edbf5fe4f3404ac0936b06f0e97d717e Mon Sep 17 00:00:00 2001 From: kkolinko Date: Tue, 14 Jul 2009 00:01:01 +0000 Subject: [PATCH] 1. Ensure that any user defined CLASSPATH variables are not used on startup (as is already implemented since rev.303663), but now allow them to be specified in setenv.sh, in rare case when it is needed. 2. When preparing the CLASSPATH, do not treat the "debug" command specially, because jdb does not need the tools.jar file. 3. Remove some wrong quotes in tool-wrapper.bat. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@793757 13f79535-47bb-0310-9956-ffa450edef68 --- bin/catalina.bat | 6 ++++++ bin/catalina.sh | 4 ++++ bin/setclasspath.bat | 8 -------- bin/setclasspath.sh | 10 ---------- bin/tool-wrapper.bat | 12 +++++++++--- bin/tool-wrapper.sh | 5 +++++ 6 files changed, 24 insertions(+), 21 deletions(-) diff --git a/bin/catalina.bat b/bin/catalina.bat index 8eb8dfaa3..64672bb56 100755 --- a/bin/catalina.bat +++ b/bin/catalina.bat @@ -88,6 +88,10 @@ echo This environment variable is needed to run this program goto end :okHome +rem Ensure that any user defined CLASSPATH variables are not used on startup, +rem but allow them to be specified in setenv.bat, in rare case when it is needed. +set CLASSPATH= + rem Get standard environment variables if "%CATALINA_BASE%" == "" goto gotSetenvHome if exist "%CATALINA_BASE%\bin\setenv.bat" call "%CATALINA_BASE%\bin\setenv.bat" @@ -107,6 +111,8 @@ call "%CATALINA_HOME%\bin\setclasspath.bat" %1 if errorlevel 1 goto end 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 diff --git a/bin/catalina.sh b/bin/catalina.sh index ad72ca2eb..0b9d7a4cb 100755 --- a/bin/catalina.sh +++ b/bin/catalina.sh @@ -103,6 +103,10 @@ PRGDIR=`dirname "$PRG"` # Only set CATALINA_HOME if not already set [ -z "$CATALINA_HOME" ] && CATALINA_HOME=`cd "$PRGDIR/.." ; 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_BASE"/bin/setenv.sh ]; then . "$CATALINA_BASE"/bin/setenv.sh elif [ -r "$CATALINA_HOME"/bin/setenv.sh ]; then diff --git a/bin/setclasspath.bat b/bin/setclasspath.bat index 62404d9b7..ffa221399 100755 --- a/bin/setclasspath.bat +++ b/bin/setclasspath.bat @@ -67,14 +67,6 @@ rem Set the default -Djava.endorsed.dirs argument set JAVA_ENDORSED_DIRS=%BASEDIR%\endorsed :gotEndorseddir -rem Set standard CLASSPATH -rem Note that there are no quotes as we do not want to introduce random -rem quotes into the CLASSPATH -if not exist "%JAVA_HOME%\lib\tools.jar" goto noJavac -if not ""%1"" == ""debug"" goto noJavac -set CLASSPATH=%JAVA_HOME%\lib\tools.jar -:noJavac - 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 JAVA_HOME may contain spaces. diff --git a/bin/setclasspath.sh b/bin/setclasspath.sh index e9a59de5b..4c559f2a3 100755 --- a/bin/setclasspath.sh +++ b/bin/setclasspath.sh @@ -21,9 +21,6 @@ # $Id$ # ----------------------------------------------------------------------------- -# First clear out the user classpath -CLASSPATH= - # Make sure prerequisite environment variables are set if [ -z "$JAVA_HOME" -a -z "$JRE_HOME" ]; then # Bugzilla 37284 (reviewed). @@ -101,13 +98,6 @@ if [ -z "$JAVA_ENDORSED_DIRS" ]; then JAVA_ENDORSED_DIRS="$BASEDIR"/endorsed fi -# Set standard CLASSPATH -if [ "$1" = "debug" ] ; then - if [ -f "$JAVA_HOME"/lib/tools.jar ]; then - CLASSPATH="$JAVA_HOME"/lib/tools.jar - fi -fi - # OSX hack to CLASSPATH JIKESPATH= if [ `uname -s` = "Darwin" ]; then diff --git a/bin/tool-wrapper.bat b/bin/tool-wrapper.bat index 5393d730d..6a7561d38 100755 --- a/bin/tool-wrapper.bat +++ b/bin/tool-wrapper.bat @@ -45,6 +45,10 @@ echo This environment variable is needed to run this program goto end :okHome +rem Ensure that any user defined CLASSPATH variables are not used on startup, +rem but allow them to be specified in setenv.bat, in rare case when it is needed. +set CLASSPATH= + rem Get standard environment variables if exist "%CATALINA_HOME%\bin\setenv.bat" call "%CATALINA_HOME%\bin\setenv.bat" @@ -58,11 +62,13 @@ set BASEDIR=%CATALINA_HOME% call "%CATALINA_HOME%\bin\setclasspath.bat" 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 +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 +set CLASSPATH=%CATALINA_HOME%\bin\bootstrap.jar;%BASEDIR%\lib\servlet-api.jar :okclasspath rem Get remaining unshifted command line arguments and save them in the diff --git a/bin/tool-wrapper.sh b/bin/tool-wrapper.sh index d94a716e9..89acc66f4 100755 --- a/bin/tool-wrapper.sh +++ b/bin/tool-wrapper.sh @@ -55,6 +55,11 @@ done # Get standard environment variables PRGDIR=`dirname "$PRG"` CATALINA_HOME=`cd "$PRGDIR/.." ; 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 fi -- 2.11.0