Skip to content

Commit

Permalink
Set case statement to support multiple jar URI's and enabled the 'fil…
Browse files Browse the repository at this point in the history
…e' URI to load the main-class
  • Loading branch information
Brennon York committed Dec 11, 2014
1 parent 8d20936 commit c6dad68
Showing 1 changed file with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,25 @@ private[spark] class SparkSubmitArguments(args: Seq[String], env: Map[String, St

// Try to set main class from JAR if no --class argument is given
if (mainClass == null && !isPython && primaryResource != null) {
try {
val uri = new URI(primaryResource)
val jar = new JarFile(uri.getPath)
// Note that this might still return null if no main-class is set; we catch that later
mainClass = jar.getManifest.getMainAttributes.getValue("Main-Class")
} catch {
case e: Exception =>
SparkSubmit.printErrorAndExit("Cannot load main class from JAR: " + primaryResource)
val uri = new URI(primaryResource)
val uriScheme = uri.getScheme()
// Note that this might still return null if no main-class is set; we catch that later
mainClass = uriScheme match {
case "file" => {
try {
val jar = new JarFile(uri.getPath)
jar.getManifest.getMainAttributes.getValue("Main-Class")
} catch {
case e: Exception =>
SparkSubmit.printErrorAndExit("Cannot load main class from JAR: " + primaryResource)
return
}
}
case _ => {
SparkSubmit.printErrorAndExit("Cannot load main class from JAR: " + primaryResource +
" with URI: " + uriScheme)
return
}
}
}

Expand Down

0 comments on commit c6dad68

Please sign in to comment.