Skip to content

Commit

Permalink
SPARK-1710: spark-submit should print better errors than "InvocationT…
Browse files Browse the repository at this point in the history
…argetException"

Catching the InvocationTargetException, printing getTargetException.

Author: Sandeep <sandeep@techaddict.me>

Closes #630 from techaddict/SPARK-1710 and squashes the following commits:

834d79b [Sandeep] changes from srowen  suggestions
109d604 [Sandeep] SPARK-1710: spark-submit should print better errors than "InvocationTargetException"
  • Loading branch information
techaddict authored and pwendell committed May 5, 2014
1 parent bcb9b7f commit b48a55a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.spark.deploy

import java.io.{File, PrintStream}
import java.lang.reflect.InvocationTargetException
import java.net.{URI, URL}

import scala.collection.mutable.{ArrayBuffer, HashMap, Map}
Expand Down Expand Up @@ -137,7 +138,7 @@ object SparkSubmit {
throw new Exception(msg)
}
}

// Special flag to avoid deprecation warnings at the client
sysProps("SPARK_SUBMIT") = "true"

Expand Down Expand Up @@ -253,7 +254,14 @@ object SparkSubmit {

val mainClass = Class.forName(childMainClass, true, loader)
val mainMethod = mainClass.getMethod("main", new Array[String](0).getClass)
mainMethod.invoke(null, childArgs.toArray)
try {
mainMethod.invoke(null, childArgs.toArray)
} catch {
case e: InvocationTargetException => e.getCause match {
case cause: Throwable => throw cause
case null => throw e
}
}
}

private def addJarToClasspath(localJar: String, loader: ExecutorURLClassLoader) {
Expand Down

0 comments on commit b48a55a

Please sign in to comment.