写点什么

java 使用 hbase、hadoop 报错举例

作者:刘大猫
  • 2025-09-27
    黑龙江
  • 本文字数:2396 字

    阅读完需:约 8 分钟

@[TOC]

摘要

总结自己 springboot 项目使用 hbase、hadoop 中出现的莫名奇怪的依赖使用报错


hbase   2.0.2版本hadoop  3.1.1版本
复制代码


==注意==:本地依赖版本最好和服务器上版本一致,避免发生莫名奇怪错误

情况 1:NoClassDefFoundError

java.lang.NoClassDefFoundError: org/apache/hadoop/tracing/SpanReceiverHost  at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:643) ~[api-gateway-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]  at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:628) ~[api-gateway-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]  at org.apache.hadoop.hdfs.DistributedFileSystem.initialize(DistributedFileSystem.java:149) ~[api-gateway-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]  at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:3354) ~[api-gateway-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]  at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:124) ~[api-gateway-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]  at org.apache.hadoop.fs.FileSystem$Cache.getInternal(FileSystem.java:3403) ~[api-gateway-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]  at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:3371) ~[api-gateway-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]  at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:477) ~[api-gateway-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]  at org.apache.hadoop.fs.FileSystem$1.run(FileSystem.java:216) ~[api-gateway-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]  at org.apache.hadoop.fs.FileSystem$1.run(FileSystem.java:213) ~[api-gateway-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]  at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_231]  at javax.security.auth.Subject.doAs(Subject.java:422) ~[na:1.8.0_231]  at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1729) ~[api-gateway-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]  at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:213) ~[api-gateway-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]  at com.geespace.microservices.directory.assets.service.impl.DataAssetsScreenServiceImpl.updateAssetsSize(DataAssetsScreenServiceImpl.java:149) ~[api-gateway-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]  at com.geespace.microservices.directory.assets.service.impl.DataAssetsScreenServiceImpl$$FastClassBySpringCGLIB$$cc83a803.invoke(<generated>) ~[api-gateway-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]  at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[api-gateway-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]  at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749) ~[api-gateway-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[api-gateway-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]  at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294) ~[api-gateway-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]  at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98) ~[api-gateway-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[api-gateway-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]  at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115) ~[api-gateway-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]  at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_231]  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_231]  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_231]  at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_231]Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.tracing.SpanReceiverHost  at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_231]  at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[na:1.8.0_231]  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355) ~[na:1.8.0_231]  at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[na:1.8.0_231]  ... 27 common frames omitted  
复制代码


==原因==:碰到这种 xxxxxClass 未找到,就说明服务器上使用 jar 包版本不对,导致找不到类,原因就是 jar 出现多版本导致的,这个类出现在 hadoop-common 2.7.7 中,而我要使用的是 3.1.1 版本,不应该出现这个对象



==解决思路==:pom 依赖使用<exclusion>标签进行依赖冲突排除,确保最后只有一个版本即可(也就是把乱七八糟 jar 内部引入的版本全部排除调)

情况 2:使用 hbase 报错:NullPointerException

下面这句使用报错 ↓


 FileSystem fs = FileSystem.get(new URI(hdfsPath), configuration, hdfsName);
复制代码


==原因==:报空指针就是没有进行初始化,而直接调用方法导致的==解决思路==:写到一起或者初始化后再使用即可

情况 3:summary.typeQuotaInfos.typeQuotaInfo[3].type

查看这篇文章即可 -> : https://blog.csdn.net/a924382407/article/details/117441247?spm=1001.2014.3001.5501

用户头像

刘大猫

关注

还未添加个人签名 2022-08-23 加入

还未添加个人简介

评论

发布
暂无评论
java使用hbase、hadoop报错举例_人工智能_刘大猫_InfoQ写作社区