From 5ae378bc585aac611bcd60817d89734732219fac Mon Sep 17 00:00:00 2001 From: Sakthi Date: Wed, 17 Apr 2019 13:17:59 -0700 Subject: [PATCH] HBASE-22264: Rest Server (master branch) on jdk 11 throws NoClassDefFoundError : javax/annotation/Priority --- bin/hbase | 59 +++++++++++++++++++ .../src/main/assembly/hadoop-two-compat.xml | 8 +++ 2 files changed, 67 insertions(+) diff --git a/bin/hbase b/bin/hbase index 1af2213001e4f85d93ee8f46cf460c78b3179121..7115324a103392174e05e65f16fe10c805214512 100755 --- a/bin/hbase +++ b/bin/hbase @@ -441,6 +441,14 @@ add_maven_deps_to_classpath() { CLASSPATH=${CLASSPATH}:$(cat "${f}") } +add_jdk11_deps_to_classpath() { + for f in ${HBASE_HOME}/lib/jdk11/*; do + if [ -f "${f}" ]; then + CLASSPATH="${CLASSPATH}:${f}" + fi + done +} + #Add the development env class path stuff if $in_dev_env; then add_maven_deps_to_classpath "cached_classpath.txt" @@ -649,6 +657,57 @@ else CLASS=$COMMAND fi +# Add lib/jdk11 jars to the classpath + +if [ "${DEBUG}" = "true" ]; then + echo "Deciding on addition of lib/jdk11 jars to the classpath" +fi + +addJDK11Jars=false + +if [ "${HBASE_JDK11}" != "" ]; then + # Use the passed Environment Variable HBASE_JDK11 + if [ "${DEBUG}" = "true" ]; then + echo "HBASE_JDK11 set. Will use it instead of deciding based on JDK version." + fi + if [ "${HBASE_JDK11}" = "include" ]; then + addJDK11Jars=true + if [ "${DEBUG}" = "true" ]; then + echo "HBASE_JDK11 set as 'include' hence adding JDK11 jars to classpath." + fi + elif [ "${HBASE_JDK11}" != "exclude" ]; then + echo "[HBASE_JDK11] contains unsupported value(s) - ${HBASE_JDK11}. Ignoring passed value." + echo "[HBASE_JDK11] supported values: [include, exclude]." + fi +else + # Use JDK detection + JAVA=$JAVA_HOME/bin/java + version=$(JAVA -version 2>&1 | awk -F '"' '/version/ {print $2}') + if [ "${DEBUG}" = "true" ]; then + echo "HBASE_JDK11 not set hence using JDK detection. Extracted JDK version - ${version}" + fi + + # -gt doesn't support floating points (e.g. 11.0.2) hence using '>' instead [shellcheck] + # shellcheck disable=SC2071 + if [[ "$version" > "11" ]]; then + if [ "${DEBUG}" = "true" ]; then + echo "Version ${version} is greater than 11 hence adding JDK11 jars to classpath." + fi + addJDK11Jars=true + elif [ "${DEBUG}" = "true" ]; then + echo "Version ${version} is lesser than 11 hence skipping JDK11 jars from classpath." + fi +fi + +if [ "${addJDK11Jars}" = "true" ]; then + add_jdk11_deps_to_classpath + if [ "${DEBUG}" = "true" ]; then + echo "Added JDK11 jars to classpath." + fi +elif [ "${DEBUG}" = "true" ]; then + echo "JDK11 jars skipped from classpath." +fi + # Have JVM dump heap if we run out of memory. Files will be 'launch directory' # and are named like the following: java_pid21612.hprof. Apparently it doesn't # 'cost' to have this flag enabled. Its a 1.6 flag only. See: diff --git a/hbase-assembly/src/main/assembly/hadoop-two-compat.xml b/hbase-assembly/src/main/assembly/hadoop-two-compat.xml index 9aada987189d11cddf0abf90c7ac682e9cf5fed2..99252dee8e2ff68b4c0e865cd11d562c727ac406 100644 --- a/hbase-assembly/src/main/assembly/hadoop-two-compat.xml +++ b/hbase-assembly/src/main/assembly/hadoop-two-compat.xml @@ -68,6 +68,7 @@ javax.annotation:javax.annotation-api + com.sun.activation:javax.activation com.sun.xml.ws:jaxws-ri org.jruby:jruby-complete @@ -191,6 +192,13 @@ jline:jline + + lib/jdk11 + + com.sun.activation:javax.activation + javax.annotation:javax.annotation-api + + -- 2.20.1 (Apple Git-117)