scala版本在火花2.1.0中不匹配

时间:2017-02-10 15:12:16

标签: java scala apache-spark apache-kafka spark-streaming

当我使用spark 1.6.1时,一切都很好。当我切换到Spark 2.1.0时,我遇到了以下问题:

  

stage3.0中的任务33失败了4次;中止工作

     

线程“main”org.apache.spark.SparkException中的异常:由于阶段失败而中止作业:阶段3.0中的任务33失败4次,最近失败:阶段3.0中失去了33.3(TID 310,192.168.1.5) ,executor 3):java.io.invalidclassexception scala.tuple2;本地班级不相容;本地类不兼容:stream classdesc serialVersionUID = -4864544146559264103,本地类serialVersionUID = 3356420310891166197

我知道-4864544146559264103对应于scala 2.10,而3356420310891166197对应于scala 2.11。虽然我将配置更改为

编辑:整个pom文件显示如下。

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>test.spark</groupId>
  <artifactId>spark</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>spark</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <build>
    <plugins>
      <plugin>
        <!-- solve the problem of : java.lang.ClassNotFoundException: kafka.producer.ProducerConfig -->
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.4</version>
        <configuration>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
        </configuration>
        <executions>
          <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.6.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-streaming_2.11</artifactId>
      <version>2.1.0</version>
    </dependency>
    <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-core_2.11</artifactId>
      <version>2.1.0</version>
    </dependency>
    <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-mllib_2.11</artifactId>
      <version>2.1.0</version>
    </dependency>
    <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-streaming-kafka-0-8_2.11</artifactId>
      <version>2.1.0</version>
    </dependency>
    <dependency>
      <groupId>org.apache.hbase</groupId>
      <artifactId>hbase-server</artifactId>
      <version>1.1.2</version>
    </dependency>
    <dependency>
      <groupId>org.apache.hbase</groupId>
      <artifactId>hbase-client</artifactId>
      <version>1.1.2</version>
    </dependency>
    <dependency>
      <groupId>org.apache.hbase</groupId>
      <artifactId>hbase-common</artifactId>
      <version>1.1.2</version>
    </dependency>
    <dependency>
      <groupId>io.fastjson</groupId>
      <artifactId>boon</artifactId>
      <version>0.33</version>
    </dependency>
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <version>2.7</version>
    </dependency>
    <dependency>
      <groupId>com.googlecode.json-simple</groupId>
      <artifactId>json-simple</artifactId>
      <version>1.1.1</version>
    </dependency>
  </dependencies>
</project>

问题仍然存在。如何解决这个问题?将添加所需的任何细节。谢谢你的帮助!

1 个答案:

答案 0 :(得分:0)

最后,我解决了这个问题。这是我的错,pom文件没问题,项目运作良好。

问题是由一个细节引起的,代码从HDFS读取scala.Tuple2对象,这在我的问题中没有提到(我很抱歉这样说)。 HDFS中的对象是由另一个项目的scala 2.10生成的,因此会出现问题。

无论如何,谢谢你的帮助。