Could not locate executable null\bin\winutils.exe in the hadoop binary path

    CDH5环境,客户端调用HBase JAVA API做查询,报错如下:

    

10:02:13,492 [main] ERROR  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:278)
	at org.apache.hadoop.util.Shell.getWinUtilsPath(Shell.java:300)
	at org.apache.hadoop.util.Shell.<clinit>(Shell.java:293)
	at org.apache.hadoop.util.StringUtils.<clinit>(StringUtils.java:76)
	at org.apache.hadoop.conf.Configuration.getTrimmedStrings(Configuration.java:1546)
	at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:556)
	at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:490)
	at org.apache.hadoop.hdfs.DistributedFileSystem.initialize(DistributedFileSystem.java:136)
	at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:2433)
	at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:88)
	at org.apache.hadoop.fs.FileSystem$Cache.getInternal(FileSystem.java:2467)
	at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2449)
	at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:367)
	at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:166)
        ....

 

    搞笑的解决方案:

    在代码中添加如下:

    

File workaround = new File(".");
        System.getProperties().put("hadoop.home.dir", workaround.getAbsolutePath());
        new File("./bin").mkdirs();
        new File("./bin/winutils.exe").createNewFile();

    bug地址:https://issues.cloudera.org/browse/DISTRO-544

你可能感兴趣的:(hadoop)