Could not locate executable null\bin\winutils.exe in the Hadoop binaries

在本地调试hadoop和spark程序时一直报一个错误Could not locate executable null\bin\winutils.exe in the Hadoop binaries:,看起来像是HADOOP_HOME没有配置,但我明明配置了啊,检查了好几遍也没发现问题,跟进取可以看到在hadoop.util.Shell中有一个checkHadoopHome的方法,
private static String checkHadoopHome() {

    // first check the Dflag hadoop.home.dir with JVM scope
    String home = System.getProperty("hadoop.home.dir");

    // fall back to the system/user-global env variable
    if (home == null) {
      home = System.getenv("HADOOP_HOME");
    }

    try {
       // couldn't find either setting for hadoop's home directory
       if (home == null) {
         throw new IOException("HADOOP_HOME or hadoop.home.dir are not set.");
       }

       if (home.startsWith("\"") && home.endsWith("\"")) {
         home = home.substring(1, home.length()-1);
       }

       // check that the home setting is actually a directory that exists
       File homedir = new File(home);
       if (!homedir.isAbsolute() || !homedir.exists() || !homedir.isDirectory()) {
         throw new IOException("Hadoop home directory " + homedir
           + " does not exist, is not a directory, or is not an absolute path.");
       }

       home = homedir.getCanonicalPath();

    } catch (IOException ioe) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Failed to detect a valid hadoop home directory", ioe);
      }
      home = null;
    }
    
    return home;
  }


可以看到它首先是从hadoop.home.dir这个系统变量中获取,无奈只好在运行时通过System.setProperty("hadoop.home.dir", "E:/asWorkSpace/hadoop")来进行手动配置,后来实在想不明白,就一步步调试了一下,发现是在if (!homedir.isAbsolute() || !homedir.exists() || !homedir.isDirectory())这一步出了问题,”E:/asWorkSpace/hadoop“即不是绝对路径,也不存在,这就搞不懂了,没办法只好将HADOOP_HOME配置成“E://asWorkSpace//hadoop”的形式,问题解决了,不用每次手动设置了,但是为啥HADOOP_HOME的路径设置和JAVA_HOME的格式不一样,我还是没搞懂,不知道还有没有人碰到过这个奇怪的问题。


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值