HBASE-20187 Shell startup fails with IncompatibleClassChangeError

Signed-off-by: Josh Elser <elserj@apache.org>
This commit is contained in:
Balazs Meszaros 2018-03-13 16:38:46 +01:00 committed by Josh Elser
parent 5e2f8e4023
commit 8fdb61955f
2 changed files with 46 additions and 28 deletions

View File

@ -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

View File

@ -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>