Author: kkolinko Date: Wed Apr 23 12:38:58 2014 New Revision: 1589390 URL: http://svn.apache.org/r1589390 Log: * Fix http://issues.apache.org/bugzilla/show_bug.cgi?id=56143 and http://issues.apache.org/bugzilla/show_bug.cgi?id=49993
Improve service.bat so that it can be launched from a non-UAC console, and backport other minor improvements. Update documentation. There is no more a need to start cmd.exe with elevated priviledges. Add support for '<version-major/>', '<version-major-minor>' to tomcat-docs.xsl to simplify documentation backports. (I am not backporting the "/user" option of service.bat. The rest of service.bat is the same as in TC7 and TC8.) Changes to service.bat: - Improve service.bat so that it can be launched from a non-UAC console. This includes using a single call to tomcat6.exe to install the Windows service rather than three calls, and using command line arguments instead of environment variables to pass the settings. (BZ 56143) - Align options with *.exe Windows installer. This affects --Classpath, --DisplayName, --StartPath, --StopPath and --LogPath. - Make command comparisons case-insensitive. Remove %OS% check for setlocal. (This assumes that nobody runs on ancient non-NT systems that do not have setlocal). - Improve check for JAVA_HOME and add support for JRE_HOME environment variable. (BZ 49993) - Print a warning in case if neither server nor client jvm is found. Modified: tomcat/tc6.0.x/trunk/STATUS.txt tomcat/tc6.0.x/trunk/bin/service.bat tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml tomcat/tc6.0.x/trunk/webapps/docs/tomcat-docs.xsl tomcat/tc6.0.x/trunk/webapps/docs/windows-service-howto.xml Modified: tomcat/tc6.0.x/trunk/STATUS.txt URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=1589390&r1=1589389&r2=1589390&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/STATUS.txt (original) +++ tomcat/tc6.0.x/trunk/STATUS.txt Wed Apr 23 12:38:58 2014 @@ -41,45 +41,6 @@ PATCHES PROPOSED TO BACKPORT: +1: markt, remm -1: -* Fix http://issues.apache.org/bugzilla/show_bug.cgi?id=56143 - and http://issues.apache.org/bugzilla/show_bug.cgi?id=49993 - - Improve service.bat so that it can be launched from a non-UAC console, - and backport other minor improvements. - - Update documentation. There is no more a need to start cmd.exe with - elevated priviledges. - - Add support for '<version-major/>', '<version-major-minor>' to - tomcat-docs.xsl to simplify documentation backports. - - (I am not backporting the "/user" option of service.bat. The rest of - service.bat is the same as in TC7 and TC8.) - - Changes to service.bat: - - - Improve service.bat so that it can be launched from a non-UAC console. - This includes using a single call to tomcat6.exe to install the Windows - service rather than three calls, and using command line arguments instead - of environment variables to pass the settings. (BZ 56143) - - - Align options with *.exe Windows installer. This affects --Classpath, - --DisplayName, --StartPath, --StopPath and --LogPath. - - - Make command comparisons case-insensitive. Remove %OS% check for setlocal. - - (This assumes that nobody runs on ancient non-NT systems that do not have - setlocal). - - - Improve check for JAVA_HOME and add support for JRE_HOME environment - variable. (BZ 49993) - - - Print a warning in case if neither server nor client jvm is found. - - https://people.apache.org/~kkolinko/patches/2014-04-14_tc6_56143_v2.patch - +1: kkolinko, markt, remm - -1: - * Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=56369 Ensure that removing an MBean notification listener reverts all the operations performed when adding an MBean notification Modified: tomcat/tc6.0.x/trunk/bin/service.bat URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/bin/service.bat?rev=1589390&r1=1589389&r2=1589390&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/bin/service.bat (original) +++ tomcat/tc6.0.x/trunk/bin/service.bat Wed Apr 23 12:38:58 2014 @@ -14,7 +14,6 @@ rem WITHOUT WARRANTIES OR CONDITIONS OF rem See the License for the specific language governing permissions and rem limitations under the License. -if "%OS%" == "Windows_NT" setlocal rem --------------------------------------------------------------------------- rem NT Service Install/Uninstall script rem @@ -24,9 +23,11 @@ rem Service is in rem remove Remove the service from the System. rem rem name (optional) If the second argument is present it is considered -rem to be new service name +rem to be new service name rem --------------------------------------------------------------------------- +setlocal + rem Guess CATALINA_HOME if not defined set "CURRENT_DIR=%cd%" if not "%CATALINA_HOME%" == "" goto gotHome @@ -37,16 +38,34 @@ cd .. set "CATALINA_HOME=%cd%" :gotHome if exist "%CATALINA_HOME%\bin\tomcat@VERSION_MAJOR@.exe" goto okHome -echo The tomcat.exe was not found... +echo The tomcat@VERSION_MAJOR@.exe was not found... echo The CATALINA_HOME environment variable is not defined correctly. echo This environment variable is needed to run this program goto end +:okHome rem Make sure prerequisite environment variables are set -if not "%JAVA_HOME%" == "" goto okHome -echo The JAVA_HOME environment variable is not defined +if not "%JAVA_HOME%" == "" goto gotJdkHome +if not "%JRE_HOME%" == "" goto gotJreHome +echo Neither the JAVA_HOME nor the JRE_HOME environment variable is defined +echo Service will try to guess them from the registry. +goto okJavaHome +:gotJreHome +if not exist "%JRE_HOME%\bin\java.exe" goto noJavaHome +if not exist "%JRE_HOME%\bin\javaw.exe" goto noJavaHome +goto okJavaHome +:gotJdkHome +if not exist "%JAVA_HOME%\jre\bin\java.exe" goto noJavaHome +if not exist "%JAVA_HOME%\jre\bin\javaw.exe" goto noJavaHome +if not exist "%JAVA_HOME%\bin\javac.exe" goto noJavaHome +if not "%JRE_HOME%" == "" goto okJavaHome +set "JRE_HOME=%JAVA_HOME%\jre" +goto okJavaHome +:noJavaHome +echo The JAVA_HOME environment variable is not defined correctly echo This environment variable is needed to run this program -goto end -:okHome +echo NB: JAVA_HOME should point to a JDK not a JRE +goto end +:okJavaHome if not "%CATALINA_BASE%" == "" goto gotBase set "CATALINA_BASE=%CATALINA_HOME%" :gotBase @@ -55,17 +74,23 @@ set "EXECUTABLE=%CATALINA_HOME%\bin\tomc rem Set default Service name set SERVICE_NAME=Tomcat@VERSION_MAJOR@ -set PR_DISPLAYNAME=Apache Tomcat @VERSION_MAJOR@ +set DISPLAYNAME=Apache Tomcat @VERSION_MAJOR_MINOR@ %SERVICE_NAME% -if "%1" == "" goto displayUsage -if "%2" == "" goto setServiceName -set SERVICE_NAME=%2 -set PR_DISPLAYNAME=Apache Tomcat %2 -:setServiceName -if %1 == install goto doInstall -if %1 == remove goto doRemove -if %1 == uninstall goto doRemove +if "x%1x" == "xx" goto displayUsage +set SERVICE_CMD=%1 +shift +if "x%1x" == "xx" goto checkServiceCmd +set SERVICE_NAME=%1 +set DISPLAYNAME=Apache Tomcat @VERSION_MAJOR_MINOR@ %1 +shift +if "x%1x" == "xx" goto checkServiceCmd echo Unknown parameter "%1" +goto displayUsage +:checkServiceCmd +if /i %SERVICE_CMD% == install goto doInstall +if /i %SERVICE_CMD% == remove goto doRemove +if /i %SERVICE_CMD% == uninstall goto doRemove +echo Unknown parameter "%SERVICE_CMD%" :displayUsage echo. echo Usage: service.bat install/remove [service_name] @@ -73,7 +98,15 @@ goto end :doRemove rem Remove the service -"%EXECUTABLE%" //DS//%SERVICE_NAME% +echo Removing the service '%SERVICE_NAME%' ... +echo Using CATALINA_BASE: "%CATALINA_BASE%" + +"%EXECUTABLE%" //DS//%SERVICE_NAME% ^ + --LogPath "%CATALINA_BASE%\logs" +if not errorlevel 1 goto removed +echo Failed removing '%SERVICE_NAME%' service +goto end +:removed echo The service '%SERVICE_NAME%' has been removed goto end @@ -83,42 +116,46 @@ echo Installing the service '%SERVICE_NA echo Using CATALINA_HOME: "%CATALINA_HOME%" echo Using CATALINA_BASE: "%CATALINA_BASE%" echo Using JAVA_HOME: "%JAVA_HOME%" +echo Using JRE_HOME: "%JRE_HOME%" -rem Use the environment variables as an example -rem Each command line option is prefixed with PR_ - -set PR_DESCRIPTION=Apache Tomcat @VERSION@ Server - http://tomcat.apache.org/ -set "PR_INSTALL=%EXECUTABLE%" -set "PR_LOGPATH=%CATALINA_BASE%\logs" -set "PR_CLASSPATH=%CATALINA_BASE%\bin\tomcat-juli.jar;%CATALINA_HOME%\bin\tomcat-juli.jar;%CATALINA_HOME%\bin\bootstrap.jar" -rem Set the server jvm from JAVA_HOME -set "PR_JVM=%JAVA_HOME%\jre\bin\server\jvm.dll" -if exist "%PR_JVM%" goto foundJvm -rem Set the client jvm from JAVA_HOME -set "PR_JVM=%JAVA_HOME%\jre\bin\client\jvm.dll" -if exist "%PR_JVM%" goto foundJvm -set PR_JVM=auto +rem Try to use the server jvm +set "JVM=%JRE_HOME%\bin\server\jvm.dll" +if exist "%JVM%" goto foundJvm +rem Try to use the client jvm +set "JVM=%JRE_HOME%\bin\client\jvm.dll" +if exist "%JVM%" goto foundJvm +echo Warning: Neither 'server' nor 'client' jvm.dll was found at JRE_HOME. +set JVM=auto :foundJvm -echo Using JVM: "%PR_JVM%" -"%EXECUTABLE%" //IS//%SERVICE_NAME% --StartClass org.apache.catalina.startup.Bootstrap --StopClass org.apache.catalina.startup.Bootstrap --StartParams start --StopParams stop +echo Using JVM: "%JVM%" + +set "CLASSPATH=%CATALINA_HOME%\bin\bootstrap.jar;%CATALINA_BASE%\bin\tomcat-juli.jar" +if not "%CATALINA_HOME%" == "%CATALINA_BASE%" set "CLASSPATH=%CLASSPATH%;%CATALINA_HOME%\bin\tomcat-juli.jar" + +"%EXECUTABLE%" //IS//%SERVICE_NAME% ^ + --Description "Apache Tomcat @VERSION@ Server - http://tomcat.apache.org/" ^ + --DisplayName "%DISPLAYNAME%" ^ + --Install "%EXECUTABLE%" ^ + --LogPath "%CATALINA_BASE%\logs" ^ + --StdOutput auto ^ + --StdError auto ^ + --Classpath "%CLASSPATH%" ^ + --Jvm "%JVM%" ^ + --StartMode jvm ^ + --StopMode jvm ^ + --StartPath "%CATALINA_HOME%" ^ + --StopPath "%CATALINA_HOME%" ^ + --StartClass org.apache.catalina.startup.Bootstrap ^ + --StopClass org.apache.catalina.startup.Bootstrap ^ + --StartParams start ^ + --StopParams stop ^ + --JvmOptions "-Dcatalina.home=%CATALINA_HOME%;-Dcatalina.base=%CATALINA_BASE%;-Djava.endorsed.dirs=%CATALINA_HOME%\endorsed;-Djava.io.tmpdir=%CATALINA_BASE%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties" ^ + --JvmMs 128 ^ + --JvmMx 256 if not errorlevel 1 goto installed echo Failed installing '%SERVICE_NAME%' service goto end :installed -rem Clear the environment variables. They are not needed any more. -set PR_DISPLAYNAME= -set PR_DESCRIPTION= -set PR_INSTALL= -set PR_LOGPATH= -set PR_CLASSPATH= -set PR_JVM= -rem Set extra parameters -"%EXECUTABLE%" //US//%SERVICE_NAME% --JvmOptions "-Dcatalina.base=%CATALINA_BASE%;-Dcatalina.home=%CATALINA_HOME%;-Djava.endorsed.dirs=%CATALINA_HOME%\endorsed" --StartMode jvm --StopMode jvm -rem More extra parameters -set "PR_LOGPATH=%CATALINA_BASE%\logs" -set PR_STDOUTPUT=auto -set PR_STDERROR=auto -"%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions "-Djava.io.tmpdir=%CATALINA_BASE%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties" --JvmMs 128 --JvmMx 256 echo The service '%SERVICE_NAME%' has been installed. :end Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=1589390&r1=1589389&r2=1589390&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Wed Apr 23 12:38:58 2014 @@ -146,6 +146,11 @@ Correct documentation on Windows service options, aligning it with Apache Commons Daemon documentation. (kkolinko) </fix> + <add> + Add support for <code>version-major</code>, + <code>version-major-minor</code> tags in documentation XSLT, to simplify + documentation backports. (kkolinko) + </add> </changelog> </subsection> <subsection name="Other"> @@ -162,6 +167,16 @@ directory, instead of "%SystemRoot%\System32\LogFiles\Apache". (kkolinko) </update> + <update> + <bug>49993</bug>, <bug>56143</bug>: Improve <code>service.bat</code> + script. Allow it to be launched from non-UAC console. The UAC prompt + will be shown only once. Now there is no need to run the command shell + with elevated privileges. Improve check for <code>JAVA_HOME</code> + and add support for <code>JRE_HOME</code>. Warn if neither "client" + nor "server" JVM is found. Align classpath, display name and other + options with the <code>exe</code> installer. Make command names + case-insensitive. Update documentation. (kkolinko) + </update> </changelog> </subsection> </section> Modified: tomcat/tc6.0.x/trunk/webapps/docs/tomcat-docs.xsl URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/tomcat-docs.xsl?rev=1589390&r1=1589389&r2=1589390&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/webapps/docs/tomcat-docs.xsl (original) +++ tomcat/tc6.0.x/trunk/webapps/docs/tomcat-docs.xsl Wed Apr 23 12:38:58 2014 @@ -35,6 +35,8 @@ <xsl:param name="apache-logo" select="'/images/asf-logo.gif'"/> <xsl:param name="relative-path" select="'.'"/> <xsl:param name="version" select="'6.0.x'"/> + <xsl:param name="majorversion" select="'6'"/> + <xsl:param name="majorminorversion" select="'6.0'"/> <xsl:param name="build-date" select="'MMM d yyyy'"/> <xsl:param name="year" select="'yyyy'"/> <xsl:param name="void-image" select="'/images/void.gif'"/> @@ -518,6 +520,14 @@ <a href="{$link}">r<xsl:apply-templates/></a> </xsl:template> + <!-- Version numbers --> + <xsl:template match="version-major-minor"> + <xsl:value-of select="$majorminorversion"/> + </xsl:template> + <xsl:template match="version-major"> + <xsl:value-of select="$majorversion"/> + </xsl:template> + <!-- specially process td tags ala site.vsl --> <xsl:template match="table[@class='detail-table']/tr/td"> <td bgcolor="{$table-td-bg}" valign="top" align="left"> Modified: tomcat/tc6.0.x/trunk/webapps/docs/windows-service-howto.xml URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/windows-service-howto.xml?rev=1589390&r1=1589389&r2=1589390&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/webapps/docs/windows-service-howto.xml (original) +++ tomcat/tc6.0.x/trunk/webapps/docs/windows-service-howto.xml Wed Apr 23 12:38:58 2014 @@ -334,10 +334,16 @@ The safest way to manually install the s script. </p> <p> -<strong>NOTE:</strong> On Windows Vista or any other operating system with User -Account Control (UAC) you must either disable UAC or right-click on cmd.exe and -select "Run as administrator" in order to run this script. If UAC is enabled -being logged on with an Administrator account is not sufficient. +<strong>NOTE:</strong> On Windows Vista or any later operating system with User +Account Control (UAC) enabled you will be asked for additional privileges +when 'Tomcat<version-major/>.exe' is launched by the script.<br/> +If you want to pass additional options to service installer as +<code>PR_*</code> environment variables, you have to either configure them +globally in OS, or launch the program that sets them with elevated privileges +(e.g. right-click on cmd.exe and select "Run as administrator"; on Windows 8 +(or later) or Windows Server 2012 (or later), you can open an elevated command +prompt for the current directory from the Explorer +by clicking on the "File" menu bar). See issue <bug>56143</bug> for details. </p> <p> <source> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org