当前位置:   article > 正文

用java下载hdfs文件报NullPointerException

hdfs的filesystem对象 java.lang.nullpointerexception: null

用fs.copyToLocalFile( hdfsPath,localPath);下载hdfs的文件会报NullPointerException,具体报错为:

java.lang.NullPointerException
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1012)
    at org.apache.hadoop.util.Shell.runCommand(Shell.java:487)
    at org.apache.hadoop.util.Shell.run(Shell.java:460)
    at org.apache.hadoop.util.Shell$ShellCommandExecutor.execute(Shell.java:720)
    at org.apache.hadoop.util.Shell.execCommand(Shell.java:813)
    at org.apache.hadoop.util.Shell.execCommand(Shell.java:796)
    at org.apache.hadoop.fs.RawLocalFileSystem.setPermission(RawLocalFileSystem.java:656)
    at org.apache.hadoop.fs.FilterFileSystem.setPermission(FilterFileSystem.java:490)
    at org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:462)
    at org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:428)
    at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:908)
    at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:889)
    at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:786)
    at org.apache.hadoop.fs.FileUtil.copy(FileUtil.java:365)
    at org.apache.hadoop.fs.FileUtil.copy(FileUtil.java:338)
    at org.apache.hadoop.fs.FileUtil.copy(FileUtil.java:289)
    at org.apache.hadoop.fs.FileSystem.copyToLocalFile(FileSystem.java:1970)
    at org.apache.hadoop.fs.FileSystem.copyToLocalFile(FileSystem.java:1939)
    at org.apache.hadoop.fs.FileSystem.copyToLocalFile(FileSystem.java:1915)
    at hadoop.downFile.downloadFileorDirectoryOnHDFS(downFile.java:29)
    at hadoop.downFile.main(downFile.java:12)

解决方法:将fs.copyToLocalFile( hdfsPath,localPath);改为fs.copyToLocalFile( false,hdfsPath,localPath,true);

原因:不理解,但加上这两个后确实可以下载

转载于:https://www.cnblogs.com/zhuzhixijiang/p/5141454.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/木道寻08/article/detail/740555
推荐阅读
相关标签
  

闽ICP备14008679号