HBASE-20187 Shell startup fails with IncompatibleClassChangeError Signed-off-by: Josh Elser <els...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/8fdb6195 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/8fdb6195 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/8fdb6195 Branch: refs/heads/branch-2 Commit: 8fdb61955f0cb32916182e5874770a2aed38f770 Parents: 5e2f8e4 Author: Balazs Meszaros <balazs.mesza...@cloudera.com> Authored: Tue Mar 13 16:38:46 2018 +0100 Committer: Josh Elser <els...@apache.org> Committed: Wed Mar 14 15:55:22 2018 -0400 ---------------------------------------------------------------------- bin/hbase | 55 +++++++++++++++++++++++++-------------------- hbase-assembly/pom.xml | 19 ++++++++++++---- 2 files changed, 46 insertions(+), 28 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/8fdb6195/bin/hbase ---------------------------------------------------------------------- diff --git a/bin/hbase b/bin/hbase index 70cae9c..b371ffc 100755 --- a/bin/hbase +++ b/bin/hbase @@ -169,22 +169,6 @@ if [ -d "$HBASE_HOME/hbase-server/target/hbase-webapps" ]; then fi fi -add_maven_deps_to_classpath() { - f="${HBASE_HOME}/hbase-build-configuration/target/cached_classpath.txt" - if [ ! -f "${f}" ] - then - echo "As this is a development environment, we need ${f} to be generated from maven (command: mvn install -DskipTests)" - exit 1 - fi - CLASSPATH=${CLASSPATH}:`cat "${f}"` -} - - -#Add the development env class path stuff -if $in_dev_env; then - add_maven_deps_to_classpath -fi - #add the hbase jars for each module for f in $HBASE_HOME/hbase-jars/hbase*.jar; do if [[ $f = *sources.jar ]] @@ -299,6 +283,15 @@ if [ "$AUTH_AS_SERVER" == "true" ] || [ "$COMMAND" = "hbck" ]; then fi fi +# check if the command needs jline +declare -a jline_cmds=("zkcli" "org.apache.hadoop.hbase.zookeeper.ZKMainServer") +for cmd in "${jline_cmds[@]}"; do + if [[ $cmd == "$COMMAND" ]]; then + jline_needed=true + break + fi +done + # for jruby # (1) for the commands which need jruby (see jruby_cmds defined below) # A. when JRUBY_HOME is specified explicitly, eg. export JRUBY_HOME=/usr/local/share/jruby @@ -316,6 +309,27 @@ for cmd in "${jruby_cmds[@]}"; do fi done +add_maven_deps_to_classpath() { + f="${HBASE_HOME}/hbase-build-configuration/target/$1" + + if [ ! -f "${f}" ]; then + echo "As this is a development environment, we need ${f} to be generated from maven (command: mvn install -DskipTests)" + exit 1 + fi + CLASSPATH=${CLASSPATH}:$(cat "${f}") +} + +#Add the development env class path stuff +if $in_dev_env; then + add_maven_deps_to_classpath "cached_classpath.txt" + + if [[ $jline_needed ]]; then + add_maven_deps_to_classpath "cached_classpath_jline.txt" + elif [[ $jruby_needed ]]; then + add_maven_deps_to_classpath "cached_classpath_jruby.txt" + fi +fi + # the command needs jruby if [[ $jruby_needed ]]; then if [ "$JRUBY_HOME" != "" ]; then # JRUBY_HOME is specified explicitly, eg. export JRUBY_HOME=/usr/local/share/jruby @@ -326,14 +340,7 @@ if [[ $jruby_needed ]]; then HBASE_OPTS="$HBASE_OPTS -Djruby.home=$JRUBY_HOME -Djruby.lib=$JRUBY_HOME/lib" else # JRUBY_HOME is not specified explicitly - if $in_dev_env; then # in dev environment - F_JRUBY="${HBASE_HOME}/hbase-build-configuration/target/cached_classpath_jruby.txt" - if [ ! -f "${F_JRUBY}" ]; then - echo "As this is a development environment, we need ${F_JRUBY} to be generated from maven (command: mvn install -DskipTests)" - exit 1 - fi - CLASSPATH=$(cat "${F_JRUBY}"):$CLASSPATH; - else # not in dev environment + if ! $in_dev_env; then # not in dev environment # add jruby packaged with HBase to CLASSPATH JRUBY_PACKAGED_WITH_HBASE="$HBASE_HOME/lib/ruby/*.jar" for jruby_jar in $JRUBY_PACKAGED_WITH_HBASE; do http://git-wip-us.apache.org/repos/asf/hbase/blob/8fdb6195/hbase-assembly/pom.xml ---------------------------------------------------------------------- diff --git a/hbase-assembly/pom.xml b/hbase-assembly/pom.xml index 134507a..eb69d60 100644 --- a/hbase-assembly/pom.xml +++ b/hbase-assembly/pom.xml @@ -94,14 +94,25 @@ </goals> <configuration> <outputFile>${project.parent.basedir}/target/cached_classpath.txt</outputFile> - <excludeArtifactIds>jruby-complete</excludeArtifactIds> + <excludeArtifactIds>jline,jruby-complete</excludeArtifactIds> </configuration> </execution> <execution> - <!-- Generates a file containing jruby jar. - In dev environment, bin/hbase will read the file and add the jar into classpath when jruby is needed - --> + <!-- generates the file that will be used by the bin/hbase zkcli script in the dev env --> + <id>create-hbase-generated-classpath-jline</id> + <phase>test</phase> + <goals> + <goal>build-classpath</goal> + </goals> + <configuration> + <outputFile>${project.parent.basedir}/target/cached_classpath_jline.txt</outputFile> + <includeArtifactIds>jline</includeArtifactIds> + </configuration> + </execution> + + <execution> + <!-- generates the file that will be used by the bin/hbase shell script in the dev env --> <id>create-hbase-generated-classpath-jruby</id> <phase>test</phase> <goals>