本文主要是介绍解决 java.lang.NoSuchMethodError: org.apache.hadoop.fs.FSOutputSummer.(Ljava/util/zip/Checksum;II)V,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
环境: linux部署hdfs2.6.0集群,windows部署开发环境
为了学习mahout,使用网上的HdfsDAO读写远程hdfs时,ls和mkdir测试通过,但上传文件报错:
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.hadoop.fs.FSOutputSummer.<init>(Ljava/util/zip/Checksum;II)Vat org.apache.hadoop.hdfs.DFSOutputStream.<init>(DFSOutputStream.java:1553)at org.apache.hadoop.hdfs.DFSOutputStream.<init>(DFSOutputStream.java:1582)at org.apache.hadoop.hdfs.DFSOutputStream.newStreamForCreate(DFSOutputStream.java:1614)at org.apache.hadoop.hdfs.DFSClient.create(DFSClient.java:1465)at org.apache.hadoop.hdfs.DFSClient.create(DFSClient.java:1390)at org.apache.hadoop.hdfs.DistributedFileSystem$6.doCall(DistributedFileSystem.java:394)at org.apache.hadoop.hdfs.DistributedFileSystem$6.doCall(DistributedFileSystem.java:390)at org.apache.hadoop.fs.FileSystemLinkResolver.resolve(FileSystemLinkResolver.java:81)at org.apache.hadoop.hdfs.DistributedFileSystem.create(DistributedFileSystem.java:390)at org.apache.hadoop.hdfs.DistributedFileSystem.create(DistributedFileSystem.java:334)at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:909)at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:890)at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:787)at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:776)at org.playground.HadoopDFSFileReadWrite.main(HadoopDFSFileReadWrite.java:37)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:497)at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
解决方案:
参考了: http://softdevblogs.com/ 上的相关帖子
发现是 原有的pom中依赖的hadoop2.6因为与mahout 0.11.0依赖的2.4.1版而冲突,实际使用了2.4.1与线上服务器不符
排除掉mahout 0.11.0间接依赖的hadoop设置,只用自己直接设置的hadoop版本号
如:
<!-- mahout --><dependency> <groupId>org.apache.mahout</groupId> <artifactId>mahout-examples</artifactId> <version>0.11.0</version><exclusions><exclusion><artifactId>jdk.tools</artifactId><groupId>jdk.tools</groupId></exclusion><exclusion><artifactId>hadoop-client</artifactId><groupId>org.apache.hadoop</groupId></exclusion></exclusions></dependency> <dependency><groupId>org.apache.mahout</groupId><artifactId>mahout-math</artifactId><version>0.11.0</version></dependency><dependency><groupId>org.apache.mahout</groupId><artifactId>mahout-hdfs</artifactId><version>0.11.0</version><exclusions><exclusion><artifactId>hadoop-client</artifactId><groupId>org.apache.hadoop</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-common</artifactId><version>2.6.0</version><exclusions><exclusion><groupId>jdk.tools</groupId><artifactId>jdk.tools</artifactId></exclusion><exclusion><artifactId>jasper-compiler</artifactId><groupId>tomcat</groupId></exclusion><exclusion><artifactId>jasper-runtime</artifactId><groupId>tomcat</groupId></exclusion><exclusion><artifactId>servlet-api</artifactId><groupId>javax.servlet</groupId></exclusion><exclusion><artifactId>jsp-api</artifactId><groupId>javax.servlet.jsp</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hadoop</groupId> <artifactId>hadoop-hdfs</artifactId> <version>2.6.0</version> <exclusions> <exclusion> <artifactId>jdk.tools</artifactId> <groupId>jdk.tools</groupId> </exclusion> </exclusions> </dependency>
这篇关于解决 java.lang.NoSuchMethodError: org.apache.hadoop.fs.FSOutputSummer.(Ljava/util/zip/Checksum;II)V的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!