运行jar时出错-清单主要属性的签名文件摘要无效

时间:2019-07-17 17:01:55

标签: scala apache-spark apache-spark-sql

我已经在intellij IDE中使用spark 1.6.0在scala中编写了一个小程序,jar生成了,但是在运行时抛出错误。

请分享您的意见以解决此问题。

[cloudera@quickstart ~]$ spark-submit --master local --class com.sample.sample.sample /home/cloudera/Desktop/IdeaProjects.jar
Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
    at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:286)
    at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:239)
    at java.util.jar.JarVerifier.processEntry(JarVerifier.java:317)
    at java.util.jar.JarVerifier.update(JarVerifier.java:228)
    at java.util.jar.JarFile.initializeVerifier(JarFile.java:348)
    at java.util.jar.JarFile.getInputStream(JarFile.java:415)
    at sun.misc.JarIndex.getJarIndex(JarIndex.java:137)
    at sun.misc.URLClassPath$JarLoader$1.run(URLClassPath.java:674)
    at sun.misc.URLClassPath$JarLoader$1.run(URLClassPath.java:666)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.misc.URLClassPath$JarLoader.ensureOpen(URLClassPath.java:665)
    at sun.misc.URLClassPath$JarLoader.<init>(URLClassPath.java:638)
    at sun.misc.URLClassPath$3.run(URLClassPath.java:366)
    at sun.misc.URLClassPath$3.run(URLClassPath.java:356)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.misc.URLClassPath.getLoader(URLClassPath.java:355)
    at sun.misc.URLClassPath.getLoader(URLClassPath.java:332)
    at sun.misc.URLClassPath.getResource(URLClassPath.java:198)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:358)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:270)
    at org.apache.spark.util.Utils$.classForName(Utils.scala:177)
    at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:688)
    at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:181)
    at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:206)
    at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:121)
    at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)


I have tried options provided in existed thread like delete MANIFEST.MF file..etc , But no luck

package com.sample.sample

import org.apache.spark.sql.SQLContext
import org.apache.spark.{SparkConf, SparkContext}


object sample {
  def main(args: Array[String]): Unit =  {
    println("Hello World")

    val conf = new SparkConf().setAppName("JDBC App").setMaster("local")
    val sc = new SparkContext(conf)


  //  val sc = new SparkConf()
    val sqlContext = new SQLContext(sc)

    val url ="jdbc:mysql://localhost:3306/retail_db?user=root&password=cloudera"

    val df = sqlContext.read.format("jdbc").option("url", url).option("dbtable", "products").load()

    df.printSchema()
  }
}

以下是我正在运行的命令:

spark-submit --master local --class com.sample.sample.sample /home/cloudera/Desktop/IdeaProjects.jar

expecting this code should work

0 个答案:

没有答案