@@ -32,8 +32,8 @@ CLASSPATH="$SPARK_CLASSPATH:$SPARK_SUBMIT_CLASSPATH:$FWDIR/conf"
3232
3333ASSEMBLY_DIR=" $FWDIR /assembly/target/scala-$SCALA_VERSION "
3434
35- if [ -n " ${ JAVA_HOME} " ]; then
36- JAR_CMD=" ${ JAVA_HOME} /bin/jar"
35+ if [ -n " $JAVA_HOME " ]; then
36+ JAR_CMD=" $JAVA_HOME /bin/jar"
3737else
3838 JAR_CMD=" jar"
3939fi
@@ -52,28 +52,30 @@ if [ -f "$ASSEMBLY_DIR"/spark-assembly*hadoop*-deps.jar ]; then
5252 CLASSPATH=" $CLASSPATH :$FWDIR /sql/hive/target/scala-$SCALA_VERSION /classes"
5353 CLASSPATH=" $CLASSPATH :$FWDIR /yarn/stable/target/scala-$SCALA_VERSION /classes"
5454
55- DEPS_ASSEMBLY_JAR=$( ls " $ASSEMBLY_DIR " /spark-assembly* hadoop* -deps.jar 2> /dev/null)
56- CLASSPATH=" $CLASSPATH :$DEPS_ASSEMBLY_JAR "
55+ ASSEMBLY_JAR=$( ls " $ASSEMBLY_DIR " /spark-assembly* hadoop* -deps.jar 2> /dev/null)
5756else
5857 # Else use spark-assembly jar from either RELEASE or assembly directory
5958 if [ -f " $FWDIR /RELEASE" ]; then
6059 ASSEMBLY_JAR=$( ls " $FWDIR " /lib/spark-assembly* hadoop* .jar 2> /dev/null)
6160 else
6261 ASSEMBLY_JAR=$( ls " $ASSEMBLY_DIR " /spark-assembly* hadoop* .jar 2> /dev/null)
6362 fi
64- jar_error_check=$( $JAR_CMD -tf $ASSEMBLY_JAR org/apache/spark/SparkContext 2>&1 )
65- if [[ " $jar_error_check " =~ " invalid CEN header" ]]; then
66- echo " Loading Spark jar with '$JAR_CMD ' failed. "
67- echo " This is likely because Spark was compiled with Java 7 and run "
68- echo " with Java 6. (see SPARK-1703). Please use Java 7 to run Spark "
69- echo " or build Spark with Java 6."
70- exit 1
71- fi
72- CLASSPATH=" $CLASSPATH :$ASSEMBLY_JAR "
7363fi
7464
65+ # Verify that versions of java used to build the jars and run Spark are compatible
66+ jar_error_check=$( " $JAR_CMD " -tf " $ASSEMBLY_JAR " scala/AnyVal 2>&1 )
67+ if [[ " $jar_error_check " =~ " invalid CEN header" ]]; then
68+ echo " Loading Spark jar with '$JAR_CMD ' failed. "
69+ echo " This is likely because Spark was compiled with Java 7 and run "
70+ echo " with Java 6. (see SPARK-1703). Please use Java 7 to run Spark "
71+ echo " or build Spark with Java 6."
72+ exit 1
73+ fi
74+
75+ CLASSPATH=" $CLASSPATH :$ASSEMBLY_JAR "
76+
7577# When Hive support is needed, Datanucleus jars must be included on the classpath.
76- # Datanucleus jars do not work if only included in the uber jar as plugin.xml metadata is lost.
78+ # Datanucleus jars do not work if only included in the uber jar as plugin.xml metadata is lost.
7779# Both sbt and maven will populate "lib_managed/jars/" with the datanucleus jars when Spark is
7880# built with Hive, so first check if the datanucleus jars exist, and then ensure the current Spark
7981# assembly is built for Hive, before actually populating the CLASSPATH with the jars.
@@ -88,11 +90,10 @@ datanucleus_jars=$(find "$datanucleus_dir" 2>/dev/null | grep "datanucleus-.*\\.
8890datanucleus_jars=$( echo " $datanucleus_jars " | tr " \n" : | sed s/:$//g)
8991
9092if [ -n " $datanucleus_jars " ]; then
91- an_assembly_jar=${ASSEMBLY_JAR:- $DEPS_ASSEMBLY_JAR }
92- hive_files=$( jar tvf " $an_assembly_jar " org/apache/hadoop/hive/ql/exec 2> /dev/null)
93+ hive_files=$( " $JAR_CMD " -tf " $ASSEMBLY_JAR " org/apache/hadoop/hive/ql/exec 2> /dev/null)
9394 if [ -n " $hive_files " ]; then
9495 echo " Spark assembly has been built with Hive, including Datanucleus jars on classpath" 1>&2
95- CLASSPATH=$CLASSPATH :$datanucleus_jars
96+ CLASSPATH=" $CLASSPATH :$datanucleus_jars "
9697 fi
9798fi
9899
0 commit comments