运行copyToLocalFile下载文件,出现空指针错误。

来源:3-25 HDFS API编程之下载文件

IamJyeee

2020-02-05

已经按照群里的方法下载了winutil。
图片描述

也创建了类,复制了NativeIO里的内容,修改了access方法。
图片描述

再次运行copyToLocalFile下载文件,还是显示空指针错误,请老师帮忙看看是不是哪个文件位置不对,还是其他问题。

图片描述

java.lang.NullPointerException
at java.lang.ProcessBuilder.start(Unknown Source)
at org.apache.hadoop.util.Shell.runCommand(Shell.java:548)
at org.apache.hadoop.util.Shell.run(Shell.java:507)
at org.apache.hadoop.util.ShellShellCommandExecutor.execute(Shell.java:789)atorg.apache.hadoop.util.Shell.execCommand(Shell.java:882)atorg.apache.hadoop.util.Shell.execCommand(Shell.java:865)atorg.apache.hadoop.fs.RawLocalFileSystem.setPermission(RawLocalFileSystem.java:720)atorg.apache.hadoop.fs.RawLocalFileSystemShellCommandExecutor.execute(Shell.java:789) at org.apache.hadoop.util.Shell.execCommand(Shell.java:882) at org.apache.hadoop.util.Shell.execCommand(Shell.java:865) at org.apache.hadoop.fs.RawLocalFileSystem.setPermission(RawLocalFileSystem.java:720) at org.apache.hadoop.fs.RawLocalFileSystemShellCommandExecutor.execute(Shell.java:789)atorg.apache.hadoop.util.Shell.execCommand(Shell.java:882)atorg.apache.hadoop.util.Shell.execCommand(Shell.java:865)atorg.apache.hadoop.fs.RawLocalFileSystem.setPermission(RawLocalFileSystem.java:720)atorg.apache.hadoop.fs.RawLocalFileSystemLocalFSFileOutputStream.(RawLocalFileSystem.java:233)
at org.apache.hadoop.fs.RawLocalFileSystemLocalFSFileOutputStream.<init>(RawLocalFileSystem.java:217)atorg.apache.hadoop.fs.RawLocalFileSystem.createOutputStreamWithMode(RawLocalFileSystem.java:315)atorg.apache.hadoop.fs.RawLocalFileSystem.create(RawLocalFileSystem.java:303)atorg.apache.hadoop.fs.RawLocalFileSystem.create(RawLocalFileSystem.java:336)atorg.apache.hadoop.fs.ChecksumFileSystemLocalFSFileOutputStream.<init>(RawLocalFileSystem.java:217) at org.apache.hadoop.fs.RawLocalFileSystem.createOutputStreamWithMode(RawLocalFileSystem.java:315) at org.apache.hadoop.fs.RawLocalFileSystem.create(RawLocalFileSystem.java:303) at org.apache.hadoop.fs.RawLocalFileSystem.create(RawLocalFileSystem.java:336) at org.apache.hadoop.fs.ChecksumFileSystemLocalFSFileOutputStream.<init>(RawLocalFileSystem.java:217)atorg.apache.hadoop.fs.RawLocalFileSystem.createOutputStreamWithMode(RawLocalFileSystem.java:315)atorg.apache.hadoop.fs.RawLocalFileSystem.create(RawLocalFileSystem.java:303)atorg.apache.hadoop.fs.RawLocalFileSystem.create(RawLocalFileSystem.java:336)atorg.apache.hadoop.fs.ChecksumFileSystemChecksumFSOutputSummer.(ChecksumFileSystem.java:391)
at org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:454)
at org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:433)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:926)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:907)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:804)
at org.apache.hadoop.fs.FileUtil.copy(FileUtil.java:368)
at org.apache.hadoop.fs.FileUtil.copy(FileUtil.java:341)
at org.apache.hadoop.fs.FileUtil.copy(FileUtil.java:292)
at org.apache.hadoop.fs.FileSystem.copyToLocalFile(FileSystem.java:2123)
at org.apache.hadoop.fs.FileSystem.copyToLocalFile(FileSystem.java:2092)
at org.apache.hadoop.fs.FileSystem.copyToLocalFile(FileSystem.java:2068)
at com.bigdata.hadoop.hdfs.HDFSApp.copyToLocalFile(HDFSApp.java:95)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)

写回答

1回答

Michael_PK

2020-02-05

这个空指针异常就是win机器上没有正确配置成功导致的,问答区和QQ群内应该都有解决方案,需要严格每一个步骤执行,而且win那个东西一定要注意和你的hadoop版本要对应上才行。如果你想绕过这个错误可以错误,你可以在Linux上安装一个idea然后进行开发

0
0

Hadoop 系统入门+核心精讲

从Hadoop核心技术入手,掌握数据处理中ETL应用,轻松进军大数据

2397 学习 · 902 问题

查看课程