File tree Expand file tree Collapse file tree 3 files changed +35
-3
lines changed
core/src/main/scala/org/apache/spark/deploy Expand file tree Collapse file tree 3 files changed +35
-3
lines changed Original file line number Diff line number Diff line change 2424set -o posix
2525
2626CLASS=" org.apache.spark.sql.hive.thriftserver.SparkSQLCLIDriver"
27+ CLASS_NOT_FOUND_EXIT_STATUS=1
2728
2829# Figure out where Spark is installed
2930FWDIR=" $( cd ` dirname $0 ` /..; pwd) "
@@ -91,4 +92,13 @@ while (($#)); do
9192 esac
9293done
9394
94- exec " $FWDIR " /bin/spark-submit --class $CLASS " ${SUBMISSION_ARGS[@]} " spark-internal " ${CLI_ARGS[@]} "
95+ eval " $FWDIR " /bin/spark-submit --class $CLASS ${SUBMISSION_ARGS[*]} spark-internal ${CLI_ARGS[*]}
96+ exit_status=$?
97+
98+ if [[ exit_status -eq CLASS_NOT_FOUND_EXIT_STATUS ]]; then
99+ echo
100+ echo " Failed to load Spark SQL CLI main class $CLASS ."
101+ echo " You need to build Spark with -Phive."
102+ fi
103+
104+ exit $exit_status
Original file line number Diff line number Diff line change @@ -54,6 +54,8 @@ object SparkSubmit {
5454 private val SPARK_SHELL = " spark-shell"
5555 private val PYSPARK_SHELL = " pyspark-shell"
5656
57+ private val CLASS_NOT_FOUND_EXIT_STATUS = 1
58+
5759 // Exposed for testing
5860 private [spark] var exitFn : () => Unit = () => System .exit(- 1 )
5961 private [spark] var printStream : PrintStream = System .err
@@ -311,8 +313,18 @@ object SparkSubmit {
311313 System .setProperty(key, value)
312314 }
313315
314- val mainClass = Class .forName(childMainClass, true , loader)
316+ var mainClass : Class [_] = null
317+
318+ try {
319+ mainClass = Class .forName(childMainClass, true , loader)
320+ } catch {
321+ case e : ClassNotFoundException =>
322+ e.printStackTrace(printStream)
323+ System .exit(CLASS_NOT_FOUND_EXIT_STATUS )
324+ }
325+
315326 val mainMethod = mainClass.getMethod(" main" , new Array [String ](0 ).getClass)
327+
316328 try {
317329 mainMethod.invoke(null , childArgs.toArray)
318330 } catch {
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ set -o posix
2727FWDIR=" $( cd ` dirname $0 ` /..; pwd) "
2828
2929CLASS=" org.apache.spark.sql.hive.thriftserver.HiveThriftServer2"
30+ CLASS_NOT_FOUND_EXIT_STATUS=1
3031
3132function usage {
3233 echo " Usage: ./sbin/start-thriftserver [options] [thrift server options]"
@@ -75,4 +76,13 @@ while (($#)); do
7576 esac
7677done
7778
78- exec " $FWDIR " /bin/spark-submit --class $CLASS " ${SUBMISSION_ARGS[@]} " spark-internal " ${THRIFT_SERVER_ARGS[@]} "
79+ eval " $FWDIR " /bin/spark-submit --class $CLASS ${SUBMISSION_ARGS[*]} spark-internal ${THRIFT_SERVER_ARGS[*]}
80+ exit_status=$?
81+
82+ if [[ exit_status -eq CLASS_NOT_FOUND_EXIT_STATUS ]]; then
83+ echo
84+ echo " Failed to load Hive Thrift server main class $CLASS ."
85+ echo " You need to build Spark with -Phive."
86+ fi
87+
88+ exit $exit_status
You can’t perform that action at this time.
0 commit comments