一、java.lang.NoSuchMethodError: net.jpountz.lz4.LZ4BlockInputStream.<init>(Ljava/io/InputStream;Z)V

当要将dataframe进行序列化(df.show()或者df.collect())时,报这个错误。

原因是:maven的pom.xml中含有spark 和 kafka。

1.spark2.3用到了lz4-1.3.0.jar,kafka0.9.0.1用到了lz4-1.2.0.jar,而程序运行时使用的是lz4-1.3.0.jar。

2.lz4-1.3.0.jar包中net.jpountz.util.Utils 类中没有checkRange,该方法位于net.jpountz.util.SafeUtils和net.jpountz.util.UnsafeUtils

原文:https://blog.csdn.net/m0_37914799/article/details/84992275
可以通过:mvn dependency:tree|less查看冲突的包。

解决办法:

通过修改pom.xml中·kafka-client·依赖,exclude掉lz4的依赖

    <dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>${kafka.version}</version>
<exclusions>
<exclusion>
<groupId>net.jpountz.lz4</groupId>
<artifactId>lz4</artifactId>
</exclusion>
</exclusions>
</dependency>

二、java.lang.NoSuchMethodError: com.fasterxml.jackson.module.scala.deser.BigDecimalDeserializer$.handledType()Ljava/lang/Class;

原因:这个错误是Hadoop版本的fasterxml版本较低,spark的较高,

解决方法:在maven的pom.xml文件中,记住一定要在</dependencyManagement> </dependencyManagement>中加入以下库。

      <dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-scala_2.</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jaxb-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>

三、java.lang.NoSuchMethodError: io.netty.buffer.PooledByteBufAllocator.metric()Lio/netty/buffer/PooledByteBufAllocatorMetric;

加入:(也是版本不兼容)

      <dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1..Final</version>
</dependency>

四、Error:scalac: Error: org.jetbrains.jps.incremental.scala.remote.ServerException

IDEA中JDK版本和Scala不匹配,我的JDK默认为IDEA自带的JDK12,所以我换成了JDK1.8,就可以了

五、java.lang.NoClassDefFoundError: org/scalactic/source/Position

还是版本问题:原来我用的是2.2.1,然后写Scalatest时会报这个错误

import com.google.common.io.Files
import java.io.File import org.apache.commons.io.FileUtils
import org.apache.spark.sql.Row
import org.apache.spark.sql.test.SharedSparkSession
import org.scalatest.FunSuite class UrlDmpDataProcessJobTest extends FunSuite with SharedSparkSession {
val testDir = new File(".").getCanonicalPath + "/test/url"
var output: File = _ override def beforeAll() {
super.beforeAll()
output = Files.createTempDir()
}
override def afterAll() {
super.afterAll()
FileUtils.deleteDirectory(output)
} test("json parse") {
import testImplicits._
val jsonFile = testDir + "/dmp-json-data.txt"
val jsonData = spark.read.json(jsonFile).toDF()
val jsonDf = jsonData.as[UrlLoadData].filter(_ != null)
jsonDf.show()
val outputDf = UrlDmpDataParse.getJsonParseData(spark, jsonDf)
outputDf.show()
val urls = outputDf.select("urls").collect()
val pid = outputDf.select("pid").collect()
val uid = outputDf.select("uid").collect()
assert(pid === Array(Row(""),Row("")))
assert(uid === Array(Row("1bd55eb51c80733a994d853b98f46ce1"),Row("f34c9dc9f0b53cdd0972d50445759d45")))
} }

解决办法:

    <dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_${scala.binary.version}</artifactId>
<version>3.0.</version>
<scope>test</scope>
</dependency>

spark几个错误的更多相关文章

  1. Spark:相关错误总结

    http://blog.csdn.net/pipisorry/article/details/52916307 路径错误 spark FileNotFoundError: [Errno 2] No s ...

  2. 使用spark访问hive错误记录

    在spark集群中执行./spark-shell时报以下错误: 18/07/23 10:02:39 WARN DataNucleus.Connection: BoneCP specified but ...

  3. spark遇到的错误1-内存不足

    原来的代码: JavaRDD<ArticleReply> javaRdd = rdd.flatMap(new FlatMapFunction<String, ArticleReply ...

  4. 用idea+maven编译打包spark project core错误:java.lang.RuntimeException: Unable to load a Suite class

    Discovery starting. *** RUN ABORTED *** java.lang.RuntimeException: Unable to load a Suite class tha ...

  5. Spark wordcount 编译错误 -- reduceByKey is not a member of RDD

    Attempting to run http://spark.apache.org/docs/latest/quick-start.html#a-standalone-app-in-scala fro ...

  6. Spark笔记(一):错误总结

    1.转义字符: 常见的replaceAll,split,mkstring中涉及到特殊字符的都要加上转义字符,比如str.split("\\|"),str.replaceAll(&q ...

  7. 大数据学习系列之八----- Hadoop、Spark、HBase、Hive搭建环境遇到的错误以及解决方法

    前言 在搭建大数据Hadoop相关的环境时候,遇到很多了很多错误.我是个喜欢做笔记的人,这些错误基本都记载,并且将解决办法也写上了.因此写成博客,希望能够帮助那些搭建大数据环境的人解决问题. 说明: ...

  8. Spark存储管理(读书笔记)

    Spark存储管理(读书笔记) 转载请注明出处:http://www.cnblogs.com/BYRans/ Spark的存储管理 RDD的存放和管理都是由Spark的存储管理模块实现和管理的.本文从 ...

  9. 【原创】大数据基础之Hive(5)hive on spark

    hive 2.3.4 on spark 2.4.0 Hive on Spark provides Hive with the ability to utilize Apache Spark as it ...

随机推荐

  1. vue路由传参的三种方式

    方式一 通过query方式传参 这种情况下 query传递的参数会显示在url后面 this.$router.push({ path: '/detail', query: { id: id } }) ...

  2. C#使用KingAOP实现AOP面向切面编程一

    AOP面向切面编程(Aspect Oriented Programming),是通过预编译方式和运行期动态代理实现程序功能的统一维护的一种技术. 实现AOP主要由两种方式,一种是编译时静态植入,优点是 ...

  3. CentOS系统安装启动tomcat

    我们可以通过xftp工具将tomcat文件上传至CentOS系统指定文件夹中 一.安装tomcat 进入tomcat存放目录解压: tar -zxf apache-tomcat-9.0.2.tar.g ...

  4. .net和ASP.net,c#的区别

    .NET.C#和ASP.NET三者之间的区别如下: 一.什么是.NET?.NET是微软公司下的一个开发平台,.NET核心就是.NET Framwork(.NET框架)是.NET程序开发和运行的环境,在 ...

  5. python,pycharm,anaconda之间的区别与联系 - python基础入门(2)

    Python环境配置-Pycharm下载/Anaconda安装 中我们已经完成了 Pycharm 和Anaconda 的安装.可能对于刚接触的小伙伴还是比较懵逼的,一会python一会Anaconda ...

  6. 用gcd库函数求最大公约数

    如何直接调用库函数来求最大公约数呢? 1.首先看怎样求两个数的最大公约数 要注意gcd()前面是两个“_” !!! #include<bits/stdc++.h> using namesp ...

  7. python学习-21 集合 2

    集合的其他方法 1.交差补集 math = {'xm','xh','xg','xx'} english ={'xm','xh','dm','john'} print(math.symmetric_di ...

  8. Django Simple Captcha的使用

    Django Simple Captcha的使用 1.下载Django Simple Captcha django-simple-captcha官方文档地址 http://django-simple- ...

  9. ubuntu 快捷方式添加 applications添加

    首先我们要了解,Ubuntu 的 Dash 里所有程序都是在 /usr/share/applications 中的,所以我们的思路很简单——建一个类似于“快捷方式”一样的东西扔进去就好了.所以第一步自 ...

  10. (三)Spring框架之事务管理

    一.编程式事务管理 Spring事务管理器的接口是org.springframework.transaction.PlatformTransactionManager,事务管理器接口PlatformT ...