HBase中报错 java.lang.NoClassDefFoundError: com/google/protobuf/LiteralByteString
Protobuf(全称 Protocol Buffers)是 Google 开发的一种数据描述语言,能够将结构化数据序列化,可用于数据存储、通信协议等方面。在 HBase 里面用使用了 Protobuf 的类库。
版本:
HBase:1.3.1
MySQL:8.0.13
错误报告
org.apache.hadoop.hbase.DoNotRetryIOException: java.lang.NoClassDefFoundError: com/google/protobuf/LiteralByteString
原因分析
运行mvn dependency:tree后发现MySQL8.0.13中有com.google.protobuf:protobuf-java:jar:3.6.1:compile。
查看了3.6.x的protobuf 的源码,里面并没有LiteralByteString这个类。
https://github.com/protocolbuffers/protobuf/tree/3.6.x/java/core/src/main/java/com/google/protobuf
查看了2.6.1及以下版本的protobuf 的源码,里面存在LiteralByteString这个类。
https://github.com/google/protobuf/blob/v2.5.0/java/src/main/java/com/google/protobuf/LiteralByteString.java
解决方法尝试
将maven中的MySQL8.0.13的引入注释掉或MySQL版本换成低版本,如5.0.7,可以正常运行。
原因猜测
应用程序已经获得了另外一个版本的Protobuf(如3.6.1)并将其放在类路径中。建议在应用程序上运行mvn dependency:tree以查看它是否正在拾取不兼容的Protobuf依赖项(可能是传递性的)。如果应用程序的Maven依赖关系看起来很好,那么当你启动应用程序并拾取一个不正确的Protobuf版本时,可能是在运行时重载了类路径。
解决办法
1、降低protobuf版本(实操可用)
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>2.5.0</version>
</dependency>
2、将客户端的Protobuf类库重命名(尝试了下还是不行,应该是我本身项目哪还有问题)
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<relocations>
<relocation>
<pattern>com.google.protobuf</pattern>
<shadedPattern>com.fazi.google.protobuf</shadedPattern>
</relocation>
</relocations>
</configuration>
</plugin>
</plugins>
</build>
3、使用hbase-shaded-client(实操可用)
hbase-shaded-client是社区里有人将HBase里面比较常见的依赖进行了重命名,在pom文件中我们可以将引入的hbase-client替换成hbase-shaded-client
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-shaded-client</artifactId>
<version>1.3.1</version>
</dependency>
参考地址:
https://stackoverflow.com/questions/41734330/protobuf-error-hbase-createtable-put-in-java-codeprotobuf-literalbytestring
https://www.iteblog.com/archives/2463.html
---------------------
作者:发孖、
来源:CSDN
原文:https://blog.csdn.net/xcf111/article/details/86692591
版权声明:本文为博主原创文章,转载请附上博文链接!
HBase中报错 java.lang.NoClassDefFoundError: com/google/protobuf/LiteralByteString的更多相关文章
- 阿里大鱼短信发送,放到项目中报错Java.lang.NoClassDefFoundError:com/aliyuncs/exceptions/ClientException,已解决
由于项目中使用的短信服务发送的消息太慢,所以把采用了阿里大鱼的短信服务,花费了几个小时,通过审核,发现可以单独运行.但是,放到web项目中会报错(Java.lang.NoClassDefFoundEr ...
- Caused by: java.lang.NoClassDefFoundError: com/google/common/base/MoreObjects
环境:jdk1.8 开发工具:IDEA 说明:今天在做springboot集成swagger2的时候,在启动程序的时候,报错 报错信息: Error starting ApplicationConte ...
- 浏览器启动不起来java.lang.NoClassDefFoundError: com/google/common/base/Function
java.lang.NoClassDefFoundError: com/google/common/base/Function 原因:只有以下两个包 解决方案:导入 selenium-server-s ...
- 一个困扰很久的异常—java.lang.NoClassDefFoundError: com/google/gson/Gson
描述: 这个异常是在运行时抛出的,编译的时候没有任何问题,而且异常信息非常少,只有一句:java.lang.NoClassDefFoundError: com/google/gson/Gson 解决: ...
- 出现java.lang.NoClassDefFoundError: com/google/common/base/Charsets异常错误
使用selenium,出现java.lang.NoClassDefFoundError: com/google/common/base/Charsets异常错误 原因:selenium-server- ...
- Selenium 运行时出现错误(java.lang.NoClassDefFoundError: com/google/common/base/Function)
已经写好了java脚本,点击运行的过程中如果出现如下的错误提示时: java.lang.NoClassDefFoundError: com/google/common/base/Function 问题 ...
- 解决:启动项目报错 java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory
前言:项目在 spring-mvc.xml 文件中配置了上传文件拦截,结果启动报错 java.lang.NoClassDefFoundError: org/apache/commons/fileupl ...
- 公司拷贝回家的工程用sts导入clean package报错java.lang.NoClassDefFoundError
从公司拷贝工程回家加班,用相同版本的sts和jdk但是run as maven build clean package 总是报错java.lang.NoClassDefFoundError: ...
- Intellij IDEA 报错java.lang.NoClassDefFoundError
Intellij IDEA 报错java.lang.NoClassDefFoundError 11-Aug-2018 23:48:24.686 严重 [http-nio-8080-exec-5] or ...
随机推荐
- MySQL 中事务的实现
在关系型数据库中,事务的重要性不言而喻,只要对数据库稍有了解的人都知道事务具有 ACID 四个基本属性,而我们不知道的可能就是数据库是如何实现这四个属性的: 在这篇文章中,我们将对事务的实现进行分析, ...
- Java并发知识概述
1.Java内存模型的抽象结构 Java中,所有的实例.静态域和数组元素都存储在堆内存中,堆内存是线程共享的.局部变量,形参,异常处理参数不会在线程之间共享,所以不存在内存可见性问题,也就不受内存模型 ...
- 织梦简洁机械设备dedecms模板
织梦简洁机械设备dedecms模板,个人网站模板,dedecms模板. 模板地址:http://www.huiyi8.com/sc/7269.html
- Linux_服务器_03_xxx is not in the sudoers file.This incident will be reported.的解决方法
1.切换到root用户下,怎么切换就不用说了吧,不会的自己百度去. 2.添加sudo文件的写权限,命令是:chmod u+w /etc/sudoers 3.编辑sudoers文件vi /etc/sud ...
- C++ string的查找函数和npos特殊值
STL中的string有6个查找函数: 1.find() 2.rfind() 从最后一个字符开始往前找. 3.find_first_of() 4.find_not_first_of() 5.find_ ...
- 暑假集训Chapter1 贪心
为什么要今天写呢? 明天全力研究Johnson和一些奇奇怪怪的贪心 今天把能写的都写了 T1T2太水了直接上代码吧 #include<bits/stdc++.h> #define LL l ...
- Tomcat加载servlet类文件
问题1:tomcat什么时候加载servlet? 有两种情况 一种是启动时加载 一种是请求时加载 第一种是在web.xml中的<servlet>节点下增加类似:<load-on-st ...
- jdk、tomcat如何配置环境变量
一.安装JDK和Tomcat 1,安装JDK:直接运行jdk-7-windows-i586.exe可执行程序,默认安装即可. 备注:路径可以其他盘符,不建议路径包含中文名及特殊符号. 2.安装Tomc ...
- Ubuntu vim使用
vim安装:apt-get install vim-gtk vim使用:默认启动插入模式,或者按‘I’进入插入模式,退出插入模式按‘esc’,用冒号‘:wq’进行保存退出: 其复制和粘贴是靠鼠标右键中 ...
- SpringMVC之七:SpringMVC中使用Interceptor拦截器
SpringMVC 中的Interceptor 拦截器也是相当重要和相当有用的,它的主要作用是拦截用户的请求并进行相应的处理.比如通过它来进行权限验证,或者是来判断用户是否登陆,或者是像12306 那 ...