运行 Fat Jar with Spark 2.0 on cluster with only Spark 1.6 support

Running Fat Jar with Spark 2.0 on cluster with only Spark 1.6 support

我正在尝试 运行 Cloudera 集群上的 Spark 2.1 应用程序,它尚不支持 Spark 2。

我在关注答案:

这似乎是正确的,但是我在 spark-submit 期间遇到了一个奇怪的错误:

Exception in thread "main" java.lang.NoSuchMethodError: scala.runtime.IntRef.create(I)Lscala/runtime/IntRef;
    at scopt.OptionParser.parse(options.scala:370)
    at com.rxcorp.cesespoke.config.WasherConfig$.parse(WasherConfig.scala:22)
    at com.rxcorp.cesespoke.Process$.main(Process.scala:27)
    at com.rxcorp.cesespoke.Process.main(Process.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:729)
    at org.apache.spark.deploy.SparkSubmit$.doRunMain(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)

使用 我添加的提示:

spark-submit \
  ...
  --conf 'spark.executor.extraJavaOptions=-verbose:class' \
  --conf 'spark.driver.extraJavaOptions=-verbose:class' \
  ...

只是看看,正如答案中所说 - 我们 运行宁在错误的类路径上!查看日志,我可以清楚地发现:

[Loaded scala.runtime.IntRef from file:/opt/cloudera/parcels/CDH-5.8.4-1.cdh5.8.4.p0.5/jars/spark-assembly-1.6.0-cdh5.8.4-hadoop2.6.0-cdh5.8.4.jar]

这显然是问题的根源。

从头开始仔细检查给定的帖子后:

You should use spark-submit from the newer Spark installation (I'd suggest using the latest and greatest 2.1.1 as of this writing) and bundle all Spark jars as part of your Spark application.

这就是我要遵循的方式!

我还推荐阅读: http://www.mostlymaths.net/2017/05/shading-dependencies-with-sbt-assembly.html

Exception in thread "main" java.lang.NoSuchMethodError: scala.runtime.IntRef.create(I)Lscala/runtime/IntRef;

NoSuchMethodError 通常表示 jar 版本不匹配。由于缺少的方法在 scala.runtime 包中,问题很可能是由于使用一个版本的 Scala(比如 2.11)编译代码,然后 运行 将其与另一个版本 (2.10) 编译造成的。

使用 -verbose:class 参数检查 build.sbt (scalaVersion := ...) 和 运行 JVM 中的 Scala 版本,以确保这些 Scala 版本匹配。