mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

jvergara
25.35.2007 b7bbff3851444b4390c87e23a846c5bdcab2700f
Fix for issue 1273 (exception if JAVA_HOME undefined in scripts).

The fix consists of modifying the scripts to launch the InstallDS classwith a test option using the JVM
that was found. If the JVM can be successfully launched, the JVM is compatible with 1.5, if not we as
sume that is not compatible with JDK 1.5.

The downside of the fix is that it requires an additional start of the JVM each time the command line i
s launched. That is why the fix only applies to setup, uninstall, upgrade, start and stop command lines. The modifications in _server-script.* and _client-script.sh just modify the message displayed when a JVM could not be found (informing that JDK 1.5 or later can be used).
8 files modified
71 ■■■■ changed files
opends/resource/bin/_client-script.bat 3 ●●●● patch | view | raw | blame | history
opends/resource/bin/_client-script.sh 3 ●●●● patch | view | raw | blame | history
opends/resource/bin/_server-script.bat 2 ●●● patch | view | raw | blame | history
opends/resource/bin/_server-script.sh 3 ●●●● patch | view | raw | blame | history
opends/resource/bin/start-ds 19 ●●●●● patch | view | raw | blame | history
opends/resource/bin/start-ds.bat 11 ●●●●● patch | view | raw | blame | history
opends/resource/bin/stop-ds 19 ●●●●● patch | view | raw | blame | history
opends/resource/bin/stop-ds.bat 11 ●●●●● patch | view | raw | blame | history
opends/resource/bin/_client-script.bat
@@ -58,10 +58,9 @@
:noSetJavaHome
echo Error: JAVA_HOME environment variable is not set.
echo        Please set it to a valid Java 5 installation.
echo        Please set it to a valid Java 5 (or later) installation.
goto end
:setClassPath
FOR %%x in ("%DIR_HOME%\lib\*.jar") DO call "%DIR_HOME%\bat\setcp.bat" %%x
opends/resource/bin/_client-script.sh
@@ -67,7 +67,7 @@
      then
        export JAVA_BIN
      else
        echo "Please set JAVA_HOME to the root of a Java 5.0 installation."
        echo "Please set JAVA_HOME to the root of a Java 5 (or later) installation."
        exit 1
      fi
    fi
@@ -99,6 +99,5 @@
done
export CLASSPATH
# Launch the appropriate server utility.
"${JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} "${OPENDS_INVOKE_CLASS}" "${@}"
opends/resource/bin/_server-script.bat
@@ -58,7 +58,7 @@
:noSetJavaHome
echo Error: JAVA_HOME environment variable is not set.
echo        Please set it to a valid Java 5 installation.
echo        Please set it to a valid Java 5 (or later) installation.
goto end
:setClassPath
opends/resource/bin/_server-script.sh
@@ -67,7 +67,7 @@
      then
        export JAVA_BIN
      else
        echo "Please set JAVA_HOME to the root of a Java 5.0 installation."
        echo "Please set JAVA_HOME to the root of a Java 5 (or later) installation."
        exit 1
      fi
    fi
@@ -99,7 +99,6 @@
done
export CLASSPATH
# Launch the appropriate server utility.
"${JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} "${OPENDS_INVOKE_CLASS}" \
     --configClass org.opends.server.extensions.ConfigFileHandler \
opends/resource/bin/start-ds
@@ -103,6 +103,25 @@
SCRIPT_NAME_ARG="-Dorg.opends.server.scriptName=start-ds"
export SCRIPT_NAME_ARG
# Test that the provided JDK is 1.5 compatible.
if test -z "${JAVA_ARGS}"
then
  "${JAVA_BIN}" org.opends.server.tools.InstallDS -t 2> /dev/null
  if test ${?} -ne 0
  then
    echo "ERROR:  The detected Java version could not be used.  Please set "
    echo "        JAVA_HOME to the root of a Java 5.0 installation."
    exit 1
  fi
else
  "${JAVA_BIN}" ${JAVA_ARGS} org.opends.server.tools.InstallDS -t 2> /dev/null
  if test ${?} -ne 0
  then
    echo "ERROR:  The detected Java version could not be used with the specified"
    echo "Java arguments.  Please set  JAVA_HOME to the root of a Java 5.0 installation."
    exit 1
  fi
fi
# See if the provided set of arguments were sufficient for us to be able to
# start the server or perform the requested operation.  An exit code of 99
opends/resource/bin/start-ds.bat
@@ -48,7 +48,12 @@
:noSetJavaHome
echo Error: JAVA_HOME environment variable is not set.
echo        Please set it to a valid Java 5 installation.
echo        Please set it to a valid Java 5 (or later) installation.
goto end
:noValidJavaHome
echo ERROR:  The detected Java version could not be used.  Please set
echo         JAVA_HOME to to a valid Java 5 (or later) installation.
goto end
:setClassPath
@@ -58,6 +63,10 @@
set SCRIPT_NAME_ARG=-Dorg.opends.server.scriptName=start-ds
rem Test that the provided JDK is 1.5 compatible.
"%JAVA_BIN%" org.opends.server.tools.InstallDS -t > NUL 2>&1
if not %errorlevel% == 0 goto noValidJavaHome
"%JAVA_BIN%" -Xms8M -Xmx8M org.opends.server.core.DirectoryServer --configClass org.opends.server.extensions.ConfigFileHandler --configFile "%DIR_HOME%\config\config.ldif" --checkStartability %*
if %errorlevel% == 98 goto serverAlreadyStarted
opends/resource/bin/stop-ds
@@ -104,6 +104,25 @@
SCRIPT_NAME_ARG="-Dorg.opends.server.scriptName=stop-ds"
export SCRIPT_NAME_ARG
# Test that the provided JDK is 1.5 compatible.
if test -z "${JAVA_ARGS}"
then
  "${JAVA_BIN}" org.opends.server.tools.InstallDS -t 2> /dev/null
  if test ${?} -ne 0
  then
    echo "ERROR:  The detected Java version could not be used.  Please set "
    echo "        JAVA_HOME to the root of a Java 5.0 installation."
    exit 1
  fi
else
  "${JAVA_BIN}" ${JAVA_ARGS} org.opends.server.tools.InstallDS -t 2> /dev/null
  if test ${?} -ne 0
  then
    echo "ERROR:  The detected Java version could not be used with the specified"
    echo "Java arguments.  Please set  JAVA_HOME to the root of a Java 5.0 installation."
    exit 1
  fi
fi
"${JAVA_BIN}" ${JAVA_ARGS} ${SCRIPT_NAME_ARG} \
  org.opends.server.tools.StopDS --checkStoppability "${@}"
opends/resource/bin/stop-ds.bat
@@ -51,12 +51,21 @@
:noSetJavaHome
echo Error: JAVA_HOME environment variable is not set.
echo        Please set it to a valid Java 5 installation.
echo        Please set it to a valid Java 5 (or later) installation.
goto end
:noValidJavaHome
echo ERROR:  The detected Java version could not be used.  Please set
echo         JAVA_HOME to to a valid Java 5 (or later) installation.
goto end
:setClassPath
FOR %%x in ("%DIR_HOME%\lib\*.jar") DO call "%DIR_HOME%\bat\setcp.bat" %%x
rem Test that the provided JDK is 1.5 compatible.
"%JAVA_BIN%" org.opends.server.tools.InstallDS -t > NUL 2>&1
if not %errorlevel% == 0 goto noValidJavaHome
"%JAVA_BIN%" -Xms8M -Xmx8M %SCRIPT_NAME_ARG%  org.opends.server.tools.StopDS --checkStoppability %*
if %errorlevel% == 98 goto serverAlreadyStopped