Repository: spark
Updated Branches:
  refs/heads/branch-1.0 40d05a48c -> 2f091d5ef


SPARK-1703 Warn users if Spark is run on JRE6 but compiled with JDK7.

This add some guards and good warning messages if users hit this issue. /cc 
@aarondav with whom I discussed parts of the design.

Author: Patrick Wendell <[email protected]>

Closes #627 from pwendell/jdk6 and squashes the following commits:

a38a958 [Patrick Wendell] Code review feedback
94e9f84 [Patrick Wendell] SPARK-1703 Warn users if Spark is run on JRE6 but 
compiled with JDK7.
(cherry picked from commit 0c98a8f6a761b941a9e0cf6fde6df8d0b8d24057)

Signed-off-by: Patrick Wendell <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/2f091d5e
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/2f091d5e
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/2f091d5e

Branch: refs/heads/branch-1.0
Commit: 2f091d5ef0a0420bed1fd7d516190a671f085644
Parents: 40d05a4
Author: Patrick Wendell <[email protected]>
Authored: Sun May 4 12:22:23 2014 -0700
Committer: Patrick Wendell <[email protected]>
Committed: Sun May 4 12:22:38 2014 -0700

----------------------------------------------------------------------
 bin/compute-classpath.sh | 14 ++++++++++++++
 bin/spark-class          |  9 ++++++++-
 make-distribution.sh     | 14 ++++++++++++++
 3 files changed, 36 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/2f091d5e/bin/compute-classpath.sh
----------------------------------------------------------------------
diff --git a/bin/compute-classpath.sh b/bin/compute-classpath.sh
index 70ac71e..8dc547b 100755
--- a/bin/compute-classpath.sh
+++ b/bin/compute-classpath.sh
@@ -32,6 +32,12 @@ 
CLASSPATH="$SPARK_CLASSPATH:$SPARK_SUBMIT_CLASSPATH:$FWDIR/conf"
 
 ASSEMBLY_DIR="$FWDIR/assembly/target/scala-$SCALA_VERSION"
 
+if [ -n "${JAVA_HOME}" ]; then
+  JAR_CMD="${JAVA_HOME}/bin/jar"
+else
+  JAR_CMD="jar"
+fi
+
 # First check if we have a dependencies jar. If so, include binary classes 
with the deps jar
 if [ -f "$ASSEMBLY_DIR"/spark-assembly*hadoop*-deps.jar ]; then
   CLASSPATH="$CLASSPATH:$FWDIR/core/target/scala-$SCALA_VERSION/classes"
@@ -55,6 +61,14 @@ else
   else
     ASSEMBLY_JAR=`ls "$ASSEMBLY_DIR"/spark-assembly*hadoop*.jar`
   fi
+  jar_error_check=$($JAR_CMD -tf $ASSEMBLY_JAR org/apache/spark/SparkContext 
2>&1)
+  if [[ "$jar_error_check" =~ "invalid CEN header" ]]; then
+    echo "Loading Spark jar with '$JAR_CMD' failed. "
+    echo "This is likely because Spark was compiled with Java 7 and run "
+    echo "with Java 6. (see SPARK-1703). Please use Java 7 to run Spark "
+    echo "or build Spark with Java 6."
+    exit 1
+  fi
   CLASSPATH="$CLASSPATH:$ASSEMBLY_JAR"
 fi
 

http://git-wip-us.apache.org/repos/asf/spark/blob/2f091d5e/bin/spark-class
----------------------------------------------------------------------
diff --git a/bin/spark-class b/bin/spark-class
index e8160c8..72f8b9b 100755
--- a/bin/spark-class
+++ b/bin/spark-class
@@ -138,7 +138,14 @@ if [ -e "$TOOLS_DIR"/target/spark-tools*[0-9Tg].jar ]; then
 fi
 
 # Compute classpath using external script
-CLASSPATH=`$FWDIR/bin/compute-classpath.sh`
+classpath_output=$($FWDIR/bin/compute-classpath.sh)
+if [[ "$?" != "0" ]]; then
+  echo "$classpath_output"
+  exit 1
+else
+  CLASSPATH=$classpath_output
+fi
+
 if [[ "$1" =~ org.apache.spark.tools.* ]]; then
   CLASSPATH="$CLASSPATH:$SPARK_TOOLS_JAR"
 fi

http://git-wip-us.apache.org/repos/asf/spark/blob/2f091d5e/make-distribution.sh
----------------------------------------------------------------------
diff --git a/make-distribution.sh b/make-distribution.sh
index dc8aa56..2ab64ff 100755
--- a/make-distribution.sh
+++ b/make-distribution.sh
@@ -51,6 +51,20 @@ if [ $? != 0 ]; then
     exit -1;
 fi
 
+if [ -z "${JAVA_HOME}" ]; then
+  echo "Error: JAVA_HOME is not set, cannot proceed."
+  exit -1
+fi
+
+JAVA_CMD=$JAVA_HOME/bin/java
+JAVA_VERSION=$($JAVA_CMD -version 2>&1)
+if ! [[ "$JAVA_VERSION" =~ "1.6" ]]; then
+  echo "Error: JAVA_HOME must point to a JDK 6 installation (see SPARK-1703)."
+  echo "Output from 'java -version' was:"
+  echo "$JAVA_VERSION"
+  exit -1
+fi
+
 # Initialize defaults
 SPARK_HADOOP_VERSION=1.0.4
 SPARK_YARN=false

Reply via email to