Why not relying on our installer? Dont like to fork the whole script ---------- Message transféré ---------- De : <strub...@apache.org> Date : 11 mars 2015 21:01 Objet : [2/2] tomee git commit: TOMEE-1525 improve our windows bat files À : <comm...@tomee.apache.org> Cc :
TOMEE-1525 improve our windows bat files There are multiple problems * java -cp %cp% could exceed 8k -> boom Solved by leveraging the CLASSPATH jvm env param * env variables with spaces or quotes; handling fixed Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/fb8eff2f Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/fb8eff2f Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/fb8eff2f Branch: refs/heads/master Commit: fb8eff2f6bdbc2fa013beeeb7de0f3539a7ed2a7 Parents: 2539de1 Author: Mark Struberg <strub...@apache.org> Authored: Wed Mar 11 20:58:38 2015 +0100 Committer: Mark Struberg <strub...@apache.org> Committed: Wed Mar 11 20:58:38 2015 +0100 ---------------------------------------------------------------------- .../src/main/assembly/tomee-plume.xml | 6 + .../src/main/assembly/tomee-plus.xml | 6 + .../src/main/assembly/tomee-webprofile.xml | 6 + .../src/main/resources/catalina.bat | 342 +++++++++++++++++++ .../apache-tomee/src/main/resources/service.bat | 10 +- .../src/main/resources/setclasspath.bat | 99 ++++++ tomee/apache-tomee/src/main/resources/tomee.bat | 15 +- 7 files changed, 471 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/fb8eff2f/tomee/apache-tomee/src/main/assembly/tomee-plume.xml ---------------------------------------------------------------------- diff --git a/tomee/apache-tomee/src/main/assembly/tomee-plume.xml b/tomee/apache-tomee/src/main/assembly/tomee-plume.xml index 315bbf9..759d8a4 100644 --- a/tomee/apache-tomee/src/main/assembly/tomee-plume.xml +++ b/tomee/apache-tomee/src/main/assembly/tomee-plume.xml @@ -61,6 +61,8 @@ <include>service.*</include> <include>TomEE.*</include> <include>tomee.bat</include> + <include>setclasspath.bat</include> + <include>catalina.bat</include> </includes> </fileSet> <fileSet> @@ -77,6 +79,10 @@ <includes> <include>**/bin/**/*</include> </includes> + <excludes> + <exclude>**/bin/setclasspath.bat</exclude> + <exclude>**/bin/catalina.bat</exclude> + </excludes> <fileMode>0755</fileMode> </fileSet> </fileSets> http://git-wip-us.apache.org/repos/asf/tomee/blob/fb8eff2f/tomee/apache-tomee/src/main/assembly/tomee-plus.xml ---------------------------------------------------------------------- diff --git a/tomee/apache-tomee/src/main/assembly/tomee-plus.xml b/tomee/apache-tomee/src/main/assembly/tomee-plus.xml index f47249b..1851aca 100644 --- a/tomee/apache-tomee/src/main/assembly/tomee-plus.xml +++ b/tomee/apache-tomee/src/main/assembly/tomee-plus.xml @@ -61,6 +61,8 @@ <include>service.*</include> <include>TomEE.*</include> <include>tomee.bat</include> + <include>setclasspath.bat</include> + <include>catalina.bat</include> </includes> </fileSet> <fileSet> @@ -77,6 +79,10 @@ <includes> <include>**/bin/**/*</include> </includes> + <excludes> + <exclude>**/bin/setclasspath.bat</exclude> + <exclude>**/bin/catalina.bat</exclude> + </excludes> <fileMode>0755</fileMode> </fileSet> </fileSets> http://git-wip-us.apache.org/repos/asf/tomee/blob/fb8eff2f/tomee/apache-tomee/src/main/assembly/tomee-webprofile.xml ---------------------------------------------------------------------- diff --git a/tomee/apache-tomee/src/main/assembly/tomee-webprofile.xml b/tomee/apache-tomee/src/main/assembly/tomee-webprofile.xml index 4da0e68..966dc93 100644 --- a/tomee/apache-tomee/src/main/assembly/tomee-webprofile.xml +++ b/tomee/apache-tomee/src/main/assembly/tomee-webprofile.xml @@ -61,6 +61,8 @@ <include>service.*</include> <include>TomEE.*</include> <include>tomee.bat</include> + <include>setclasspath.bat</include> + <include>catalina.bat</include> </includes> </fileSet> <fileSet> @@ -77,6 +79,10 @@ <includes> <include>**/bin/**/*</include> </includes> + <excludes> + <exclude>**/bin/setclasspath.bat</exclude> + <exclude>**/bin/catalina.bat</exclude> + </excludes> <fileMode>0755</fileMode> </fileSet> </fileSets> http://git-wip-us.apache.org/repos/asf/tomee/blob/fb8eff2f/tomee/apache-tomee/src/main/resources/catalina.bat ---------------------------------------------------------------------- diff --git a/tomee/apache-tomee/src/main/resources/catalina.bat b/tomee/apache-tomee/src/main/resources/catalina.bat new file mode 100644 index 0000000..b5ca9d3 --- /dev/null +++ b/tomee/apache-tomee/src/main/resources/catalina.bat @@ -0,0 +1,342 @@ +@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 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 CATALINA_HOME May point at your Catalina "build" directory. +rem +rem CATALINA_BASE (Optional) Base directory for resolving dynamic portions +rem of a Catalina installation. If not present, resolves to +rem the same directory that CATALINA_HOME points to. +rem +rem CATALINA_OPTS (Optional) Java runtime options used when the "start", +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 +rem %CATALINA_BASE%\temp. +rem +rem JAVA_HOME Must point at your Java Development Kit installation. +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. If JRE_HOME and JAVA_HOME +rem are both set, JRE_HOME is used. +rem +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 It can also be used to update the XML parser implementation. +rem Defaults to $CATALINA_HOME/endorsed. +rem +rem JPDA_TRANSPORT (Optional) JPDA transport used when the "jpda start" +rem command is executed. The default is "dt_socket". +rem +rem JPDA_ADDRESS (Optional) Java runtime options used when the "jpda start" +rem command is executed. The default is localhost:8000. +rem +rem JPDA_SUSPEND (Optional) Java runtime options used when the "jpda start" +rem command is executed. Specifies whether JVM should suspend +rem execution immediately after startup. Default is "n". +rem +rem JPDA_OPTS (Optional) Java runtime options used when the "jpda start" +rem command is executed. If used, JPDA_TRANSPORT, JPDA_ADDRESS, +rem and JPDA_SUSPEND are ignored. Thus, all required jpda +rem options MUST be specified. The default is: +rem +rem -agentlib:jdwp=transport=%JPDA_TRANSPORT%, +rem address=%JPDA_ADDRESS%,server=y,suspend=%JPDA_SUSPEND% +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 Example (all one line) +rem set LOGGING_MANAGER="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager" +rem +rem TITLE (Optional) Specify the title of Tomcat window. The default +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 ATTENTION +rem This file is a modified version used in Apache TomEE +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 +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 + +rem Copy CATALINA_BASE from CATALINA_HOME if not defined +if not "%CATALINA_BASE%" == "" goto gotBase +set "CATALINA_BASE=%CATALINA_HOME%" +:gotBase + +rem Ensure that neither CATALINA_HOME nor CATALINA_BASE contains a semi-colon +rem as this is used as the separator in the classpath and Java provides no +rem mechanism for escaping if the same character appears in the path. Check this +rem by replacing all occurrences of ';' with '' and checking that neither +rem CATALINA_HOME nor CATALINA_BASE have changed +if "%CATALINA_HOME%" == "%CATALINA_HOME:;=%" goto homeNoSemicolon +echo Using CATALINA_HOME: "%CATALINA_HOME%" +echo Unable to start as CATALINA_HOME contains a semicolon (;) character +goto end +:homeNoSemicolon + +if "%CATALINA_BASE%" == "%CATALINA_BASE:;=%" goto baseNoSemicolon +echo Using CATALINA_BASE: "%CATALINA_BASE%" +echo Unable to start as CATALINA_BASE contains a semicolon (;) character +goto end +:baseNoSemicolon + +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 not exist "%CATALINA_BASE%\bin\setenv.bat" goto checkSetenvHome +call "%CATALINA_BASE%\bin\setenv.bat" +goto setenvDone +:checkSetenvHome +if exist "%CATALINA_HOME%\bin\setenv.bat" call "%CATALINA_HOME%\bin\setenv.bat" +:setenvDone + +rem Get standard Java environment variables +if exist "%CATALINA_HOME%\bin\setclasspath.bat" goto okSetclasspath +echo Cannot find "%CATALINA_HOME%\bin\setclasspath.bat" +echo This file is needed to run this program +goto end +:okSetclasspath +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 +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" +goto juliClasspathDone +:juliClasspathHome +set "CLASSPATH=%CLASSPATH%;%CATALINA_HOME%\bin\tomcat-juli.jar" +:juliClasspathDone + +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 Add OpenEJB javaagent +if not exist "%CATALINA_HOME%\lib\openejb-javaagent.jar" goto noOpenEJBJavaagent +set JAVA_OPTS="-javaagent:%CATALINA_HOME%\lib\openejb-javaagent.jar" %JAVA_OPTS% +:noOpenEJBJavaagent + +rem ----- Execute The Requested Command --------------------------------------- + +echo Using CATALINA_BASE: "%CATALINA_BASE%" +echo Using CATALINA_HOME: "%CATALINA_HOME%" +echo Using CATALINA_TMPDIR: "%CATALINA_TMPDIR%" +if ""%1"" == ""debug"" goto use_jdk +echo Using JRE_HOME: "%JRE_HOME%" +goto java_dir_displayed +:use_jdk +echo Using JAVA_HOME: "%JAVA_HOME%" +:java_dir_displayed +echo Using CLASSPATH: "%CLASSPATH%" + +set _EXECJAVA="%_RUNJAVA%" +set MAINCLASS=org.apache.catalina.startup.Bootstrap +set ACTION=start +set SECURITY_POLICY_FILE= +set DEBUG_OPTS= +set JPDA= + +if not ""%1"" == ""jpda"" goto noJpda +set JPDA=jpda +if not "%JPDA_TRANSPORT%" == "" goto gotJpdaTransport +set JPDA_TRANSPORT=dt_socket +:gotJpdaTransport +if not "%JPDA_ADDRESS%" == "" goto gotJpdaAddress +set JPDA_ADDRESS=localhost:8000 +:gotJpdaAddress +if not "%JPDA_SUSPEND%" == "" goto gotJpdaSuspend +set JPDA_SUSPEND=n +:gotJpdaSuspend +if not "%JPDA_OPTS%" == "" goto gotJpdaOpts +set JPDA_OPTS=-agentlib:jdwp=transport=%JPDA_TRANSPORT%,address=%JPDA_ADDRESS%,server=y,suspend=%JPDA_SUSPEND% +:gotJpdaOpts +shift +:noJpda + +if ""%1"" == ""debug"" goto doDebug +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 ... ) +echo commands: +echo debug Start Catalina in a debugger +echo debug -security Debug Catalina with a security manager +echo jpda start Start Catalina under JPDA debugger +echo run Start Catalina in the current window +echo run -security Start in the current window with security manager +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 + +:doDebug +shift +set _EXECJAVA=%_RUNJDB% +set DEBUG_OPTS=-sourcepath "%CATALINA_HOME%\..\..\java" +if not ""%1"" == ""-security"" goto execCmd +shift +echo Using Security Manager +set "SECURITY_POLICY_FILE=%CATALINA_BASE%\conf\catalina.policy" +goto execCmd + +:doRun +shift +if not ""%1"" == ""-security"" goto execCmd +shift +echo Using Security Manager +set "SECURITY_POLICY_FILE=%CATALINA_BASE%\conf\catalina.policy" +goto execCmd + +:doStart +shift +if "%TITLE%" == "" set TITLE=Tomcat +set _EXECJAVA=start "%TITLE%" "%_RUNJAVA%" +if not ""%1"" == ""-security"" goto execCmd +shift +echo Using Security Manager +set "SECURITY_POLICY_FILE=%CATALINA_BASE%\conf\catalina.policy" +goto execCmd + +:doStop +shift +set ACTION=stop +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 + + +:execCmd +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 + +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% +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% +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% +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% +goto end + +:end http://git-wip-us.apache.org/repos/asf/tomee/blob/fb8eff2f/tomee/apache-tomee/src/main/resources/service.bat ---------------------------------------------------------------------- diff --git a/tomee/apache-tomee/src/main/resources/service.bat b/tomee/apache-tomee/src/main/resources/service.bat index b061f3f..5d2efbd 100644 --- a/tomee/apache-tomee/src/main/resources/service.bat +++ b/tomee/apache-tomee/src/main/resources/service.bat @@ -27,7 +27,7 @@ IF EXIST "%~dp0jdk" ( SET "JAVA_HOME=%~dp0jdk" ) -@IF NOT "%ECHO%" == "" ECHO %ECHO% +@IF DEFINED ECHO ECHO %ECHO% @IF "%OS%" == "Windows_NT" setlocal IF "%OS%" == "Windows_NT" ( @@ -66,7 +66,7 @@ IF /i "%proc%" EQU undefined ( set "SELF=%~dp0%service.bat" rem Guess CATALINA_HOME if not defined set "CURRENT_DIR=%cd%" -if not "%CATALINA_HOME%" == "" goto gotHome +if DEFINED CATALINA_HOME goto gotHome set "CATALINA_HOME=%cd%" if exist "%CATALINA_HOME%\bin\service.bat" goto okHome rem CD to the upper dir @@ -80,8 +80,8 @@ 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 gotJdkHome -if not "%JRE_HOME%" == "" goto gotJreHome +if DEFINED JAVA_HOME goto gotJdkHome +if DEFINED 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 @@ -102,7 +102,7 @@ echo This environment variable is needed to run this program echo NB: JAVA_HOME should point to a JDK not a JRE goto end :okJavaHome -if not "%CATALINA_BASE%" == "" goto gotBase +if DEFINED CATALINA_BASE goto gotBase set "CATALINA_BASE=%CATALINA_HOME%" :gotBase http://git-wip-us.apache.org/repos/asf/tomee/blob/fb8eff2f/tomee/apache-tomee/src/main/resources/setclasspath.bat ---------------------------------------------------------------------- diff --git a/tomee/apache-tomee/src/main/resources/setclasspath.bat b/tomee/apache-tomee/src/main/resources/setclasspath.bat new file mode 100644 index 0000000..e0884fb --- /dev/null +++ b/tomee/apache-tomee/src/main/resources/setclasspath.bat @@ -0,0 +1,99 @@ +@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 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 + +rem --------------------------------------------------------------------------- +rem ATTENTION +rem This file is a modified version used in Apache TomEE +rem --------------------------------------------------------------------------- + + +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 DEFINED JRE_HOME% goto gotJreHome +if DEFINED 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 + +:needJavaHome +rem Check if we have a usable JDK +if NOT DEFINED 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 +set "JRE_HOME=%JAVA_HOME%" +goto okJava + +:noJavaHome +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 + +: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=%CATALINA_HOME%\endorsed" +:gotEndorseddir + +rem Don't override _RUNJAVA if the user has set it previously +if DEFINED _RUNJAVA goto gotRunJava +rem Set standard command for invoking Java. +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. +if DEFINED _RUNJDB goto gotRunJdb +set "_RUNJDB=%JAVA_HOME%\bin\jdb.exe" +:gotRunJdb + +goto end + +:exit +exit /b 1 + +:end +exit /b 0 http://git-wip-us.apache.org/repos/asf/tomee/blob/fb8eff2f/tomee/apache-tomee/src/main/resources/tomee.bat ---------------------------------------------------------------------- diff --git a/tomee/apache-tomee/src/main/resources/tomee.bat b/tomee/apache-tomee/src/main/resources/tomee.bat index a945bbd..18f82b1 100644 --- a/tomee/apache-tomee/src/main/resources/tomee.bat +++ b/tomee/apache-tomee/src/main/resources/tomee.bat @@ -20,7 +20,7 @@ set port=8080 rem Guess CATALINA_HOME if not defined set "CURRENT_DIR=%cd%" -if not "%CATALINA_HOME%" == "" goto gotHome +if DEFINED CATALINA_HOME goto gotHome set "CATALINA_HOME=%CURRENT_DIR%" if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome cd .. @@ -35,7 +35,7 @@ goto end :okHome rem Copy CATALINA_BASE from CATALINA_HOME if not defined -if not "%CATALINA_BASE%" == "" goto gotBase +if DEFINED CATALINA_BASE goto gotBase set "CATALINA_BASE=%CATALINA_HOME%" :gotBase @@ -52,8 +52,7 @@ goto end call "%CATALINA_HOME%\bin\setclasspath.bat" %1 if errorlevel 1 goto end - -if not "%CATALINA_TMPDIR%" == "" goto gotTmpdir +if DEFINED CATALINA_TMPDIR goto gotTmpdir set "CATALINA_TMPDIR=%CATALINA_BASE%\temp" :gotTmpdir @@ -61,11 +60,11 @@ set "CATALINA_TMPDIR=%CATALINA_BASE%\temp" rem create classpath setlocal enabledelayedexpansion -set cp="%CATALINA_HOME%\bin\tomcat-juli.jar" +set "CLASSPATH=%CLASSPATH%;%CATALINA_HOME%\bin\tomcat-juli.jar" set lib="%CATALINA_HOME%\lib\" echo %lib% for %%F in (%lib%/*.jar) do ( - set cp=!cp!;%%F% + set CLASSPATH=!CLASSPATH!;%%F% ) if ""%1"" == ""deploy"" goto doDeploy @@ -74,11 +73,11 @@ goto doExec :doDeploy :doUndeploy -%_RUNJAVA% -cp "%cp%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" org.apache.openejb.cli.Bootstrap %1 -s http://localhost:%port%/tomee/ejb %2 +"%_RUNJAVA%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" org.apache.openejb.cli.Bootstrap %1 -s http://localhost:%port%/tomee/ejb %2 goto end :doExec -%_RUNJAVA% -cp "%cp%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" org.apache.openejb.cli.Bootstrap %* +"%_RUNJAVA%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" org.apache.openejb.cli.Bootstrap %* goto end :end