Repository: spark
Updated Branches:
  refs/heads/branch-1.0 9f911c93d -> 64cd91dca


[SPARK-4298][Core] - The spark-submit cannot read Main-Class from Manifest.

Resolves a bug where the `Main-Class` from a .jar file wasn't being read in 
properly. This was caused by the fact that the `primaryResource` object was a 
URI and needed to be normalized through a call to `.getPath` before it could be 
passed into the `JarFile` object.

Author: Brennon York <brennon.y...@capitalone.com>

Closes #3561 from brennonyork/SPARK-4298 and squashes the following commits:

5e0fce1 [Brennon York] Use string interpolation for error messages, moved 
comment line from original code to above its necessary code segment
14daa20 [Brennon York] pushed mainClass assignment into match statement, 
removed spurious spaces, removed { } from case statements, removed return values
c6dad68 [Brennon York] Set case statement to support multiple jar URI's and 
enabled the 'file' URI to load the main-class
8d20936 [Brennon York] updated to reset the error message back to the default
a043039 [Brennon York] updated to split the uri and jar vals
8da7cbf [Brennon York] fixes SPARK-4298

(cherry picked from commit 8e14c5eb551ab06c94859c7f6d8c6b62b4d00d59)
Signed-off-by: Josh Rosen <joshro...@databricks.com>

Conflicts:
        core/src/main/scala/org/apache/spark/deploy/SparkSubmitArguments.scala


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

Branch: refs/heads/branch-1.0
Commit: 64cd91dca00c023f8079ba513d3209abd4e3057d
Parents: 9f911c9
Author: Brennon York <brennon.y...@capitalone.com>
Authored: Wed Dec 31 11:54:10 2014 -0800
Committer: Josh Rosen <joshro...@databricks.com>
Committed: Wed Dec 31 12:00:34 2014 -0800

----------------------------------------------------------------------
 .../spark/deploy/SparkSubmitArguments.scala     | 26 ++++++++++++++------
 1 file changed, 18 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/64cd91dc/core/src/main/scala/org/apache/spark/deploy/SparkSubmitArguments.scala
----------------------------------------------------------------------
diff --git 
a/core/src/main/scala/org/apache/spark/deploy/SparkSubmitArguments.scala 
b/core/src/main/scala/org/apache/spark/deploy/SparkSubmitArguments.scala
index 80a339a..c5dcf35 100644
--- a/core/src/main/scala/org/apache/spark/deploy/SparkSubmitArguments.scala
+++ b/core/src/main/scala/org/apache/spark/deploy/SparkSubmitArguments.scala
@@ -19,6 +19,7 @@ package org.apache.spark.deploy
 
 import java.io.{File, FileInputStream, IOException}
 import java.util.Properties
+import java.net.URI
 import java.util.jar.JarFile
 
 import scala.collection.JavaConversions._
@@ -114,14 +115,23 @@ private[spark] class SparkSubmitArguments(args: 
Seq[String]) {
 
     // Try to set main class from JAR if no --class argument is given
     if (mainClass == null && !isPython && primaryResource != null) {
-      try {
-        val jar = new JarFile(primaryResource)
-        // 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)
-          return
+      val uri = new URI(primaryResource)
+      val uriScheme = uri.getScheme()
+
+      uriScheme match {
+        case "file" =>
+          try {
+            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(s"Cannot load main class from JAR 
$primaryResource")
+          }
+        case _ =>
+          SparkSubmit.printErrorAndExit(
+            s"Cannot load main class from JAR $primaryResource with URI 
$uriScheme. " +
+            "Please specify a class through --class.")
       }
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to