[opencms-dev] cmsshell.bat TOMCAT_HOME env. variable determination wrong
Christoph P. Kukulies
kuku at physik.rwth-aachen.de
Fri Apr 21 09:50:25 CEST 2006
I just wanted to play a bit with cmsshell.bat (cmsshell.sh)
and found, that the mechanism after which the TOMCAT_HOME variable
is determined, seems a bit outdated.
1. Why not test for CATALINA_HOME ?
2. the test for catalina.bat seems to work no longer in tomcat 5.5
So a review of that .bat/.sh script seems to be appropriate now.
I guess the shell script is better maintained (I see CATALINA_HOME already
in there). I'm appending my version of cmsshell.bat below.
It worked under Windows XP, Tomcat 5.5.
Only I got this log4j warning:
G:\Programme\Apache_Group\Tomcat 5.5\webapps\ROOT\WEB-INF>cmsshell
Using JAVA_HOME: C:\Programme\java\jdk1.5.0_06
Using OPENCMS_HOME: .
Using CATALINA_HOME: G:\Programme\Apache_Group\Tomcat 5.5
log4j:WARN No appenders could be found for logger (org.opencms.init).
log4j:WARN Please initialize the log4j system properly.
OpenCms WEB-INF path: "G:\Programme\Apache_Group\Tomcat 5.5\webapps\ROOT\WEB-IN
F".
OpenCms property file: "G:\Programme\Apache_Group\Tomcat 5.5\webapps\ROOT\WEB-IN
F\config\opencms.properties".
Welcome to the OpenCms shell!
This is OpenCms 6.2.0.
Copyright (c) 2005 Alkacon Software GmbH
OpenCms comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to
redistribute it under certain conditions.
Please see the GNU Lesser General Public Licence for
further details.
help Shows this text.
help * Shows the signatures of all available methods.
help {string} Shows the signatures of all methods containing this string.
exit or quit Leaves this OpenCms Shell.
Guest at Online:|/>
Guest at Online:|/>
Guest at Online:|/>quit
Goodbye!
Shutting down OpenCms, version 6.2.0 in web application "ROOT"
Shutdown completed, total uptime was 00:00:33.
G:\Programme\Apache_Group\Tomcat 5.5\webapps\ROOT\WEB-INF>
--
Chris Christoph P. U. Kukulies kukulies (at) rwth-aachen.de
---------------------- cmsshell.bat (modified) ---------------------
@echo off
if "%OS%" == "Windows_NT" setlocal
rem ---------------------------------------------------------------------------
rem Script for OpenCms Shell
rem
rem Environment Variable Prequisites
rem
rem OPENCMS_HOME May point at your OpenCms "WEB-INF" directory.
rem if not, we try to guess.
rem
rem OPENCMS_OPTS (Optional) OpenCms options.
rem
rem OPENCMS_LIB (Optional) OpenCms classpath.
rem
rem CATALINA_HOME May point at your Tomcat installation directory.
rem if not, we try to guess.
rem
rem JAVA_HOME Must point at your Java Development Kit installation.
rem
rem JAVA_OPTS (Optional) Java runtime options.
rem
rem ---------------------------------------------------------------------------
rem add this options to debug OpenCms using the shell
rem set JAVA_OPTS=%JAVA_OPTS% -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000 -Djava.compiler=NONE
rem Make sure prerequisite environment variables are set
if not "%JAVA_HOME%" == "" goto gotJavaHome
echo The JAVA_HOME environment variable is not defined
echo This environment variable is needed to run this program
goto end
:gotJavaHome
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
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
:okJavaHome
rem Guess OPENCMS_HOME if not defined
if not "%OPENCMS_HOME%" == "" goto gotHome
set OPENCMS_HOME=.
if exist "%OPENCMS_HOME%\cmsshell.bat" goto okHome
set OPENCMS_HOME=WEB-INF
:gotHome
if exist "%OPENCMS_HOME%\cmsshell.bat" goto okHome
echo The OPENCMS_HOME environment variable is not defined correctly
echo This environment variable is needed to run this program
goto end
:okHome
rem Guess CATALINA_HOME if not defined
if not "%CATALINA_HOME%" == "" goto gotTomcatHome
set CATALINA_HOME=..\..
if exist "%CATALINA_HOME%\bin\catalina.bat" goto okTomcatHome
set CATALINA_HOME=..\..\..
:gotTomcatHome
if exist "%CATALINA_HOME%\conf\server.xml" goto okTomcatHome
echo The CATALINA_HOME environment variable is not defined correctly
echo This environment variable is needed to run this program
goto end
:okTomcatHome
rem Guess OPENCMS_LIB if not defined
if not "%OPENCMS_LIB%" == "" goto gotLib
set OPENCMS_LIB=%OPENCMS_HOME%\lib
:gotHome
if exist "%OPENCMS_LIB%\opencms.jar" goto okLib
echo The OPENCMS_LIB environment variable is not defined correctly
echo This environment variable is needed to run this program
goto end
:okLib
rem Add all jars in lib dir to OPENCMS_CP variable (will include a initial semicolon ";")
for %%i in ("%OPENCMS_LIB%\*.jar") do call "%OPENCMS_HOME%\cpappend.bat" %%i
rem Check for Tomcat libs
rem Add all jars in CATALINA_HOME\common\lib dir to TOMCAT_LIB variable (will include a initial semicolon ";")
for %%i in ("%CATALINA_HOME%\common\lib\*.jar") do call "%OPENCMS_HOME%\tlappend.bat" %%i
:okLib
rem ----- Execute The Requested Command ---------------------------------------
echo Using JAVA_HOME: %JAVA_HOME%
echo Using OPENCMS_HOME: %OPENCMS_HOME%
echo Using CATALINA_HOME: %CATALINA_HOME%
rem Set standard command for invoking Java.
set _RUNJAVA="%JAVA_HOME%\bin\java.exe"
set MAINCLASS=org.opencms.main.CmsShell
rem Get command line arguments and save them in
rem the CMD_LINE_ARGS environment variable
set CMD_LINE_ARGS=
:setArgs
if ""%1""=="""" goto doneSetArgs
set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
shift
goto setArgs
:doneSetArgs
@rem set opencms arguments
set CMD_LINE_ARGS=%CMD_LINE_ARGS% -base="%CD%"
rem execute OPENCMS
%_RUNJAVA% %JAVA_OPTS% -classpath "%OPENCMS_HOME%\classes%CLASSPATH%%OPENCMS_CP%%TOMCAT_LIB%" %MAINCLASS% %CMD_LINE_ARGS%
:end
More information about the opencms-dev
mailing list