hadoop 2.6.1 java.lang.nullpointerexception位于org.apache.hadoop.hdfs.dfsoutputstream.islazypersist(dfsoutputstream)java:1709)

368yc8dk  于 2021-05-29  发布在  Hadoop
关注(0)|答案(2)|浏览(300)

当我尝试在hdfs中附加到一个文件时,我得到如下异常。请告知

file.append(new Path(uri));

例外

java.lang.NullPointerException
    at org.apache.hadoop.hdfs.DFSOutputStream.isLazyPersist(DFSOutputStream.java:1709)
    at org.apache.hadoop.hdfs.DFSOutputStream.getChecksum4Compute(DFSOutputStream.java:1550)
    at org.apache.hadoop.hdfs.DFSOutputStream.<init>(DFSOutputStream.java:1560)
    at org.apache.hadoop.hdfs.DFSOutputStream.<init>(DFSOutputStream.java:1667)
    at org.apache.hadoop.hdfs.DFSOutputStream.newStreamForAppend(DFSOutputStream.java:1694)
    at org.apache.hadoop.hdfs.DFSClient.callAppend(DFSClient.java:1824)
    at org.apache.hadoop.hdfs.DFSClient.append(DFSClient.java:1885)
    at org.apache.hadoop.hdfs.DFSClient.append(DFSClient.java:1855)
    at org.apache.hadoop.hdfs.DistributedFileSystem$4.doCall(DistributedFileSystem.java:340)
    at org.apache.hadoop.hdfs.DistributedFileSystem$4.doCall(DistributedFileSystem.java:336)
    at org.apache.hadoop.fs.FileSystemLinkResolver.resolve(FileSystemLinkResolver.java:81)
    at org.apache.hadoop.hdfs.DistributedFileSystem.append(DistributedFileSystem.java:348)
    at org.apache.hadoop.hdfs.DistributedFileSystem.append(DistributedFileSystem.java:318)
    at org.apache.hadoop.fs.FileSystem.append(FileSystem.java:1164)

请注意,我只有hadoop版本2.6.1才有这个问题,但是它在版本2.7.1中运行良好

wfveoks0

wfveoks01#

这是由于版本冲突造成的。尝试更改xml文件中的依赖关系

lsmepo6l

lsmepo6l2#

问题出在apachehadoop客户端jar的版本上。在pom.xml中,我使用了最新的2.7.1版本,令我惊讶的是它与hadoop2.6.1安装不兼容。对my pom.xml的最后修改如下

<dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-client</artifactId>
            <version>2.6.1</version>
<dependency>

相关问题