java 本地类不兼容异常:从 IDE 独立运行 spark 时
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35485662/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
local class incompatible Exception: when running spark standalone from IDE
提问by Nesrine Ben mustapha
I begin to test spark. I installed spark on my local machine and run a local cluster with a single worker. when I tried to execute my job from my IDE by setting the sparconf as follows:
我开始测试火花。我在我的本地机器上安装了 spark,并用一个 worker 运行了一个本地集群。当我尝试通过如下设置 sparconf 从我的 IDE 执行我的工作时:
final SparkConf conf = new SparkConf().setAppName("testSparkfromJava").setMaster("spark://XXXXXXXXXX:7077");
final JavaSparkContext sc = new JavaSparkContext(conf);
final JavaRDD<String> distFile = sc.textFile(Paths.get("").toAbsolutePath().toString() + "dataSpark/datastores.json");*
I got this exception:
我得到了这个例外:
java.lang.RuntimeException: java.io.InvalidClassException: org.apache.spark.rpc.netty.RequestMessage; local class incompatible: stream classdesc serialVersionUID = -5447855329526097695, local class serialVersionUID = -2221986757032131007
回答by user1733158
Got it all working with below combination of versions
使用以下版本组合即可完成所有工作
Installed spark 1.6.2
安装火花1.6.2
verify with bin/spark-submit --version
使用 bin/spark-submit --version 进行验证
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.10</artifactId>
<version>1.6.2</version>
</dependency>
and
和
Scala 2.10.6 and Java 8.
Scala 2.10.6 和 Java 8。
Note it did NOTwork and have similar class incompatible issue with below versions
注意它没有不工作,也有类似的类不兼容的问题,下面版本
Scala 2.11.8 and Java 8
Scala 2.11.8 和 Java 8
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>1.6.2</version>
</dependency>
回答by Kun
It can be multiple incompatible reasons below:
可能是以下多种不兼容的原因:
- Hadoop version;
- Spark version;
- Scala version;
- ...
- Hadoop版本;
- 火花版;
- 斯卡拉版本;
- ...
For me, its Scala version , I using 2.11.Xin my IDE but official doc says:
对我来说,它的 Scala 版本,我在我的 IDE 中使用2.11.X但官方文档说:
Spark runs on Java 7+, Python 2.6+ and R 3.1+. For the Scala API, Spark 1.6.1 uses Scala 2.10. You will need to use a compatible Scala version (2.10.x).
Spark runs on Java 7+, Python 2.6+ and R 3.1+. For the Scala API, Spark 1.6.1 uses Scala 2.10. You will need to use a compatible Scala version (2.10.x).
and the xin the doc told cannot be smaller than 3if you using latest Java(1.8), cause this. Hope it will help you!
如果您使用最新的 Java(1.8),则文档中的 x不能小于 3,导致此. 希望它会帮助你!
回答by zsxwing
Looks your installed Spark version is not same as the Spark version used in your IDE.
看起来您安装的 Spark 版本与您的 IDE 中使用的 Spark 版本不同。
If you are using maven, just compare the version of the dependency declared in pom.xml and the output of bin/spark-submit --version
and make sure they are same.
如果您使用的是 maven,只需比较 pom.xml 中声明的依赖项的版本和 的输出bin/spark-submit --version
并确保它们相同。
回答by Rajeev Rathor
I faced this issue because Spark jar dependency was 2.1.0 but installed Spark Engine version is 2.0.0 Hence version mismatch, So it throws this exception.
我遇到这个问题是因为 Spark jar 依赖项是 2.1.0 但安装的 Spark Engine 版本是 2.0.0 因此版本不匹配,所以它抛出这个异常。
The root cause of this problem is version mismatch of Spark jar dependency in project and installed Spark Engine where execute spark job is running.
此问题的根本原因是项目中 Spark jar 依赖项的版本不匹配,并且安装了运行执行 Spark 作业的 Spark 引擎。
Hence verify both versions and make them identical.
因此验证两个版本并使它们相同。
Example Spark-core Jar version 2.1.0 and Spark Computation Engine version must be: 2.1.0
示例 Spark-core Jar 版本 2.1.0 和 Spark 计算引擎版本必须是:2.1.0
Spark-core Jar version 2.0.0 and Spark Computation Engine version must be: 2.0.0
Spark-core Jar 版本 2.0.0 和 Spark Computation Engine 版本必须是:2.0.0
It's working for me perfectly.
它非常适合我。