0
点赞
收藏
分享

微信扫一扫

Java开发HBase程序报错:HADOOP_HOME or hadoop.home.dir are not set.

非常帅气的昵称吧 2022-01-28 阅读 42


Java开发HBase程序报错:​​HADOOP_HOME or hadoop.home.dir are not set.​

1.报错

16:36:44.271 [main] DEBUG org.apache.hadoop.util.Shell - Failed to detect a valid hadoop home directory
java.io.IOException: HADOOP_HOME or hadoop.home.dir are not set.
at org.apache.hadoop.util.Shell.checkHadoopHome(Shell.java:302) [hadoop-common-2.6.4.jar:na]
at org.apache.hadoop.util.Shell.<clinit>(Shell.java:327) [hadoop-common-2.6.4.jar:na]
at org.apache.hadoop.util.StringUtils.<clinit>(StringUtils.java:79) [hadoop-common-2.6.4.jar:na]
at org.apache.hadoop.security.Groups.parseStaticMapping(Groups.java:116) [hadoop-common-2.6.4.jar:na]
at org.apache.hadoop.security.Groups.<init>(Groups.java:93) [hadoop-common-2.6.4.jar:na]
at org.apache.hadoop.security.Groups.<init>(Groups.java:73) [hadoop-common-2.6.4.jar:na]
at org.apache.hadoop.security.Groups.getUserToGroupsMappingService(Groups.java:293) [hadoop-common-2.6.4.jar:na]
at org.apache.hadoop.security.Groups.getUserToGroupsMappingService(Groups.java:278) [hadoop-common-2.6.4.jar:na]
at org.apache.hadoop.hbase.security.UserProvider.<clinit>(UserProvider.java:56) [hbase-common-1.4.0.jar:1.4.0]
at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(ConnectionFactory.java:214) [hbase-client-1.4.0.jar:1.4.0]
at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(ConnectionFactory.java:119) [hbase-client-1.4.0.jar:1.4.0]
at utils.HBaseUtils.<clinit>(HBaseUtils.java:26) [classes/:na]
at Test.HBaseTest.main(HBaseTest.java:12) [classes/:na]
16:36:44.272 [main] ERROR org.apache.hadoop.util.Shell - Failed to locate the winutils binary in the hadoop binary path
java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries.
at org.apache.hadoop.util.Shell.getQualifiedBinPath(Shell.java:355) [hadoop-common-2.6.4.jar:na]
at org.apache.hadoop.util.Shell.getWinUtilsPath(Shell.java:370) [hadoop-common-2.6.4.jar:na]
at org.apache.hadoop.util.Shell.<clinit>(Shell.java:363) [hadoop-common-2.6.4.jar:na]
at org.apache.hadoop.util.StringUtils.<clinit>(StringUtils.java:79) [hadoop-common-2.6.4.jar:na]
at org.apache.hadoop.security.Groups.parseStaticMapping(Groups.java:116) [hadoop-common-2.6.4.jar:na]
at org.apache.hadoop.security.Groups.<init>(Groups.java:93) [hadoop-common-2.6.4.jar:na]
at org.apache.hadoop.security.Groups.<init>(Groups.java:73) [hadoop-common-2.6.4.jar:na]
at org.apache.hadoop.security.Groups.getUserToGroupsMappingService(Groups.java:293) [hadoop-common-2.6.4.jar:na]
at org.apache.hadoop.security.Groups.getUserToGroupsMappingService(Groups.java:278) [hadoop-common-2.6.4.jar:na]
at org.apache.hadoop.hbase.security.UserProvider.<clinit>(UserProvider.java:56) [hbase-common-1.4.0.jar:1.4.0]
at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(ConnectionFactory.java:214) [hbase-client-1.4.0.jar:1.4.0]
at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(ConnectionFactory.java:119) [hbase-client-1.4.0.jar:1.4.0]
at utils.HBaseUtils.<clinit>(HBaseUtils.java:26) [classes/:na]
at Test.HBaseTest.main(HBaseTest.java:12) [classes/:na]

2.解决办法


  • step1:下载​​winutils.exe​​​包,链接地址:​​https://github.com/srccodes/hadoop-common-2.2.0-bin​​ 。然后将其放到hadoop的包(意思就是说,windows中需要解压hadoop的安装包)的bin目录下。
  • step2:在程序起始处添加语句:​​System.setProperty("hadoop.home.dir", "D:\\SoftWarePackages\\BigData\\hadoop-2.6.4");​

参考文章

  • ​​https://github.com/srccodes/hadoop-common-2.2.0-bin​​


举报

相关推荐

0 条评论