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的更多相关文章

  1. 阿里大鱼短信发送,放到项目中报错Java.lang.NoClassDefFoundError:com/aliyuncs/exceptions/ClientException,已解决

    由于项目中使用的短信服务发送的消息太慢,所以把采用了阿里大鱼的短信服务,花费了几个小时,通过审核,发现可以单独运行.但是,放到web项目中会报错(Java.lang.NoClassDefFoundEr ...

  2. Caused by: java.lang.NoClassDefFoundError: com/google/common/base/MoreObjects

    环境:jdk1.8 开发工具:IDEA 说明:今天在做springboot集成swagger2的时候,在启动程序的时候,报错 报错信息: Error starting ApplicationConte ...

  3. 浏览器启动不起来java.lang.NoClassDefFoundError: com/google/common/base/Function

    java.lang.NoClassDefFoundError: com/google/common/base/Function 原因:只有以下两个包 解决方案:导入 selenium-server-s ...

  4. 一个困扰很久的异常—java.lang.NoClassDefFoundError: com/google/gson/Gson

    描述: 这个异常是在运行时抛出的,编译的时候没有任何问题,而且异常信息非常少,只有一句:java.lang.NoClassDefFoundError: com/google/gson/Gson 解决: ...

  5. 出现java.lang.NoClassDefFoundError: com/google/common/base/Charsets异常错误

    使用selenium,出现java.lang.NoClassDefFoundError: com/google/common/base/Charsets异常错误 原因:selenium-server- ...

  6. Selenium 运行时出现错误(java.lang.NoClassDefFoundError: com/google/common/base/Function)

    已经写好了java脚本,点击运行的过程中如果出现如下的错误提示时: java.lang.NoClassDefFoundError: com/google/common/base/Function 问题 ...

  7. 解决:启动项目报错 java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory

    前言:项目在 spring-mvc.xml 文件中配置了上传文件拦截,结果启动报错 java.lang.NoClassDefFoundError: org/apache/commons/fileupl ...

  8. 公司拷贝回家的工程用sts导入clean package报错java.lang.NoClassDefFoundError

    从公司拷贝工程回家加班,用相同版本的sts和jdk但是run as    maven build   clean package 总是报错java.lang.NoClassDefFoundError: ...

  9. Intellij IDEA 报错java.lang.NoClassDefFoundError

    Intellij IDEA 报错java.lang.NoClassDefFoundError 11-Aug-2018 23:48:24.686 严重 [http-nio-8080-exec-5] or ...

随机推荐

  1. Android RelativeLayout相对布局

    RelativeLayout是相对布局控件:以控件之间相对位置或相对父容器位置进行排列. 相对布局常用属性: 子类控件相对子类控件:值是另外一个控件的id android:layout_above-- ...

  2. 织梦CMS博客风格模板

    织梦CMS博客风格模板,织梦CMS,博客模板,CMS模板.程序模板. 模板地址:http://www.huiyi8.com/sc/7248.html

  3. html5--1.3 元素的概念与3个常用标签

    html5--1.3 元素的概念与3个常用标签 学习要点 1.元素的概念 2.3个常用的标签 HTML 元素指的是从开始标签到结束标签的所有代码. 开始标签 元素内容 结束标签 <h1> ...

  4. 分享知识-快乐自己:oracle表分区详解

    从以下几个方面来整理关于分区表的概念及操作: 1)表空间及分区表的概念: 2)表分区的具体作用: 3)表分区的优缺点: 4)表分区的几种类型及操作方法: 5)对表分区的维护性操作: 1):表空间及分区 ...

  5. Cloudera Manager 5 和 CDH5 本地(离线)安装指南

    http://archive.cloudera.com/cm5/redhat/6/x86_64/cm/5.0.0/RPMS/x86_64/ http://archive-primary.clouder ...

  6. dataguard 下主备 online redo 与 standby redo log resize 重建

    环境说明: 本实验环境是一个节点的rac + 单节点 asm dg     database 与 grid 版本是 11.2.0.4 .提别提醒 如果是多节点集群,操作时需要特别注意 thread . ...

  7. hdu 1521 排列组合 —— 指数型生成函数

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=1521 标准的指数型生成函数: WA了好几遍,原来是多组数据啊囧: 注意精度,直接强制转换(int)是舍去小 ...

  8. jdk、tomcat如何配置环境变量

    一.安装JDK和Tomcat 1,安装JDK:直接运行jdk-7-windows-i586.exe可执行程序,默认安装即可. 备注:路径可以其他盘符,不建议路径包含中文名及特殊符号. 2.安装Tomc ...

  9. Linux MySQL5.5的安装

    1.安装cmake [root@server1 src]# cd /opt/ipnms/src[root@server1 src]# tar zxvf cmake-2.8.4.tar.gz[root@ ...

  10. C# 性能分析工具

    http://msdn.microsoft.com/zh-cn/vstudio/aa497289(en-us).aspx Performance This section includes infor ...