首页 > 解决方案 > Hadoop Jar FileSystemNotFoundException

问题描述

我正在运行一个 hadoop 集群并尝试使用我发送到集群的 jar 文件运行 mapreduce 作业。问题是在某些节点上它成功而在其他节点上失败。我在某些节点上看到的错误是:

Exception in thread "main" java.nio.file.FileSystemNotFoundException
        at com.sun.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:183)
        at com.sun.nio.zipfs.ZipFileSystemProvider.getPath(ZipFileSystemProvider.java:169)
        at java.nio.file.Paths.get(Paths.java:154)
        at customLib.readFile(CustomClass2.java:254)
        at customLib.access$000(CustomClass2.java:210)
        at customLib.getFieldOrder(CustomClass2.java:591)
        at customLib.run(CustomClass1.java:177)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:76)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:90)
        at customLib.main(CustomClass1.java:136)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:90)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
        at java.lang.reflect.Method.invoke(Method.java:508)
        at org.apache.hadoop.util.RunJar.run(RunJar.java:323)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:236)

我看到其他人也有类似的问题,例如这个问题的解决方案以及指向其他问题和解决方案的链接:java.nio.file.FileSystemNotFoundException when getting file from resources folder。但是,这些解决方案都不能解释为什么它可以在一个节点上运行而不是另一个节点上运行......这一定意味着我在某处有一些配置错误。

我检查了所有 hadoop xml 配置文件以及 $CLASSPATH、$PATH 和 java 运行时版本,一切似乎都是一样的。如果有人对我可以检查的内容有任何其他想法,将不胜感激 - 谢谢。

编辑:为了澄清,它试图获取的文件是打包在 JAR 中的资源。

标签: javahadoopjarmapreducenio

解决方案


这个答案帮助了我:https ://stackoverflow.com/a/14607953/7969573 。看起来失败的节点在我的 CLASSPATH 中的 #HADOOP_HOME/share/hadoop/mapreduce/ 文件夹中具有我正在运行的类的 jar 副本。当我从应用程序调用的 shell 运行 jar 时,从节点中删除 jar 解决了这个问题。我本可以更新那个 jar 并且它也可以正常工作,但是在我当前的工作流程架构下删除它更有意义。


推荐阅读