org.apache.hadoop.hdfs.DFSOutputStream.isLazyPersist上的Hadoop 2.6.1 java.lang.NullPointerException(DFSOutputStream.java:1709)

时间:2015-10-09 05:28:52

标签: java hadoop

当我尝试附加到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

工作正常

2 个答案:

答案 0 :(得分:3)

问题在于apache hadoop客户端jar的版本。在我的pom.xml中,我有最新版本2.7.1,令我惊讶的是与hadoop 2.6.1安装不兼容。 hadoop客户端jar没有向后兼容性。最终更改为我的pom。 xml如下

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

答案 1 :(得分:0)

由于版本冲突,会发生这种情况。尝试更改xml文件中的依赖关系