Juan Hernandez has uploaded a new change for review.

Change subject: tools: Use JBoss modules instead of class path
......................................................................

tools: Use JBoss modules instead of class path

Currently in order to run the tools we build the class path using mostly
the "build-classpath" script and also some ad hoc searches. This tends
to fail in environments where the jar files are installed in locations
different than expected. This patch changes the scripts that starts
the tools so that they use the JBoss modules launcher instead, thus
manual class path building is no longer required.

Backported from master commit 028ff6b8eb74f532f0d001382d19e21e488d9527.

Change-Id: I417ab6afcd169b5c094c83214b7b2b5371302d22
Signed-off-by: Juan Hernandez <juan.hernan...@redhat.com>
---
M backend/manager/tools/src/main/shell/engine-config.sh
M backend/manager/tools/src/main/shell/engine-manage-domains.sh
M backend/manager/tools/src/main/shell/engine-notifier.sh
M backend/manager/tools/src/main/shell/engine-prolog.sh.in
4 files changed, 60 insertions(+), 123 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/75/12775/1

diff --git a/backend/manager/tools/src/main/shell/engine-config.sh 
b/backend/manager/tools/src/main/shell/engine-config.sh
index d2ce524..7c43518 100755
--- a/backend/manager/tools/src/main/shell/engine-config.sh
+++ b/backend/manager/tools/src/main/shell/engine-config.sh
@@ -1,9 +1,7 @@
 #!/bin/bash
 #
 # This script is designed to run the configuration tool.
-# The script assumes all RPM dependencies were installed, so jar
-# files can be found under /usr/share/java. The tool's configuration
-# should be under the /etc directory.
+# The tool's configuration should be under the /etc directory.
 #
 
 # Load the prolog:
@@ -89,28 +87,21 @@
         exit 0
 fi
 
-CP=`\
-build-classpath \
-apache-commons-codec \
-apache-commons-collections \
-apache-commons-configuration \
-apache-commons-jxpath \
-apache-commons-lang \
-apache-commons-logging \
-log4j \
-ovirt-engine/compat \
-ovirt-engine/tools \
-ovirt-engine/utils \
-postgresql-jdbc \
-`
-
-# Verify all classpath elements available
-for f in $(echo $CP|sed 's/:/ /g')
-do
-        if [ ! -s $f ]; then
-                die "Error: can't run without missing JAR file: $f\n"
-        fi
-done
+#
+# Add this option to the java command line to enable remote debugging in
+# all IP addresses and port 8787:
+#
+# -Xrunjdwp:transport=dt_socket,address=0.0.0.0:8787,server=y,suspend=y
+#
+# Note that the "suspend=y" options is needed to suspend the execution
+# of the JVM till you connect with the debugger, otherwise it is
+# not possible to debug the execution of the main method.
+#
 
 # Run!
-exec "${JAVA_HOME}/bin/java" -cp .:$CP 
-Dlog4j.configuration="file:${ENGINE_ETC}/engine-config/log4j.xml" 
org.ovirt.engine.core.config.EngineConfig "$@"
+exec "${JAVA_HOME}/bin/java" \
+  -Dlog4j.configuration="file:${ENGINE_ETC}/engine-config/log4j.xml" \
+  -jar "${JBOSS_HOME}/jboss-modules.jar" \
+  -dependencies org.ovirt.engine.core.tools \
+  -class org.ovirt.engine.core.config.EngineConfig \
+  "$@"
diff --git a/backend/manager/tools/src/main/shell/engine-manage-domains.sh 
b/backend/manager/tools/src/main/shell/engine-manage-domains.sh
index ae10d9c..2297fdf 100755
--- a/backend/manager/tools/src/main/shell/engine-manage-domains.sh
+++ b/backend/manager/tools/src/main/shell/engine-manage-domains.sh
@@ -1,9 +1,7 @@
 #!/bin/bash
 #
 # This script is designed to run the manage domains utility.
-# The script assumes all RPM dependencies were installed, so jar
-# files can be found under /usr/share/java. The tool's configuration
-# should be under the /etc directory.
+# The tool's configuration should be under the /etc directory.
 #
 
 # Load the prolog:
@@ -91,34 +89,6 @@
         exit 0
 fi
 
-CP=\
-$CONF_DIR:`\
-build-classpath \
-apache-commons-codec \
-apache-commons-collections \
-apache-commons-configuration \
-apache-commons-jxpath \
-apache-commons-lang \
-apache-commons-logging \
-log4j \
-ovirt-engine/common \
-ovirt-engine/compat \
-ovirt-engine/tools \
-ovirt-engine/utils \
-postgresql-jdbc \
-springframework/spring-beans \
-springframework/spring-core \
-springframework/spring-tx \
-spring-ldap/spring-ldap-core \
-`
-
-for f in $(echo $CP|sed 's/:/ /g')
-do
-        if [ ! -s $f ]; then
-                die "Error: can't run without missing JAR file: $f\n"
-        fi
-done
-
 PROPERTIES_FILE=`mktemp`
 
 if [ ! -e $PROPERTIES_FILE ]; then
@@ -136,7 +106,23 @@
 LDAPServerPort=
 EOF
 
-"${JAVA_HOME}/bin/java" -cp .:$CP 
-Dlog4j.configuration="file:${ENGINE_ETC}/engine-manage-domains/log4j.xml" 
org.ovirt.engine.core.domains.ManageDomains "$@" 
-propertiesFile=$PROPERTIES_FILE
+#
+# Add this option to the java command line to enable remote debugging in
+# all IP addresses and port 8787:
+#
+# -Xrunjdwp:transport=dt_socket,address=0.0.0.0:8787,server=y,suspend=y
+#
+# Note that the "suspend=y" options is needed to suspend the execution
+# of the JVM till you connect with the debugger, otherwise it is
+# not possible to debug the execution of the main method.
+#
+
+"${JAVA_HOME}/bin/java" \
+  -Dlog4j.configuration="file:${ENGINE_ETC}/engine-manage-domains/log4j.xml" \
+  -jar "${JBOSS_HOME}/jboss-modules.jar" \
+  -dependencies org.ovirt.engine.core.tools \
+  -class org.ovirt.engine.core.domains.ManageDomains \
+  "$@" -propertiesFile=$PROPERTIES_FILE
 
 RET_VAL=$?
 
diff --git a/backend/manager/tools/src/main/shell/engine-notifier.sh 
b/backend/manager/tools/src/main/shell/engine-notifier.sh
index e8a9c80..6da0f65 100755
--- a/backend/manager/tools/src/main/shell/engine-notifier.sh
+++ b/backend/manager/tools/src/main/shell/engine-notifier.sh
@@ -166,71 +166,23 @@
     fi
 fi
 
-# Configure classpath for engine-notifier
-JAVA_LIB_HOME=/usr/share/java
-#JAVA_OPTS="-Xdebug 
-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=127.0.0.1:8787"
+#
+# Add this option to the java command line to enable remote debugging in
+# all IP addresses and port 8787:
+#
+# -Xrunjdwp:transport=dt_socket,address=0.0.0.0:8787,server=y,suspend=y
+#
+# Note that the "suspend=y" options is needed to suspend the execution
+# of the JVM till you connect with the debugger, otherwise it is
+# not possible to debug the execution of the main method.
+#
 
-# Add the configuration directory to the classpath so that configuration
-# files can be loaded as resources:
-CP="${ENGINE_ETC}/notifier"
-
-# Add the required jar files from the system wide jars directory:
-jar_names='
-    antlr
-    commons-codec
-    commons-collections
-    commons-configuration
-    commons-jxpath
-    commons-lang
-    commons-logging
-    dom4j
-    hibernate-jpa-2.0-api
-    javamail
-    log4j
-    ovirt-engine/common
-    ovirt-engine/compat
-    ovirt-engine/tools
-    ovirt-engine/utils
-    postgresql-jdbc
-    slf4j/api
-    glassfish-jaxb/jaxb-impl
-'
-for jar_name in ${jar_names}
-do
-    jar_file=${JAVA_LIB_HOME}/${jar_name}.jar
-    if [ ! -s "${jar_file}" ]
-    then
-        die "Error: can't run without missing JAR file: ${jar_file}\n" 5
-    fi
-    CP=${CP}:${jar_file}
-done
-
-# Add all the needed jar files from the oVirt Engine EAR to the classpath, but
-# try to locate them using the name and not the version. This is important
-# in order to make the script less dependent on the version of oVirt Engine
-# installed:
-jar_names='
-    hibernate-annotations
-    hibernate-commons-annotations
-    hibernate-core
-    hibernate-validator
-    validation-api
-'
-for jar_name in ${jar_names}
-do
-    jar_file=$(find ${engineLib} -regex ".*/${jar_name}.*\.jar")
-    if [ -z "${jar_file}" -o ! -s "${jar_file}" ]
-    then
-        die "Error: can't run without missing JAR file: 
${engineLib}/${jar_name}*.jar\n" 5
-    fi
-    CP=${CP}:${jar_file}
-done
-
-if [ -z "$NOTIFIER_PID" ]
-then
-    NOTIFIER_PID=/dev/null
-fi
-
-"${JAVA_HOME}/bin/java" -cp $CP $JAVA_OPTS 
org.ovirt.engine.core.notifier.Notifier $CONF_FILE 2>/dev/null &
+"${JAVA_HOME}/bin/java" \
+  -Dlog4j.configuration="file:${ENGINE_ETC}/notifier/log4j.xml" \
+  -jar "${JBOSS_HOME}/jboss-modules.jar" \
+  -dependencies org.ovirt.engine.core.tools \
+  -class org.ovirt.engine.core.notifier.Notifier \
+  "${CONF_FILE}" \
+  2>/dev/null &
 
 echo $! >$NOTIFIER_PID
diff --git a/backend/manager/tools/src/main/shell/engine-prolog.sh.in 
b/backend/manager/tools/src/main/shell/engine-prolog.sh.in
index bc76576..94542b1 100644
--- a/backend/manager/tools/src/main/shell/engine-prolog.sh.in
+++ b/backend/manager/tools/src/main/shell/engine-prolog.sh.in
@@ -20,6 +20,14 @@
         die "Can't load configuration file \"${ENGINE_VARS}\"."
     fi
     . "${ENGINE_VARS}"
+
+    # Clean the class path:
+    CLASSPATH=""
+    export CLASSPATH
+
+    # Prepare the module path:
+    JAVA_MODULEPATH="${ENGINE_USR}/modules:${JBOSS_HOME}/modules"
+    export JAVA_MODULEPATH
 }
 
 # In addition to defining the functions we also perform some tasks that


--
To view, visit http://gerrit.ovirt.org/12775
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I417ab6afcd169b5c094c83214b7b2b5371302d22
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Juan Hernandez <juan.hernan...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to