Eclipse调用HDFS API上传文件时出现了如下错误:
Exception in thread "main" java.lang.IllegalArgumentException: Wrong FS: hdfs://master:9000/user/Administrator, expected: file:/// at org.apache.hadoop.fs.FileSystem.checkPath(FileSystem.java:659) at org.apache.hadoop.fs.RawLocalFileSystem.pathToFile(RawLocalFileSystem.java:82) at org.apache.hadoop.fs.RawLocalFileSystem.deprecatedGetFileStatus(RawLocalFileSystem.java:585) at org.apache.hadoop.fs.RawLocalFileSystem.getFileLinkStatusInternal(RawLocalFileSystem.java:803) at org.apache.hadoop.fs.RawLocalFileSystem.getFileStatus(RawLocalFileSystem.java:580) at org.apache.hadoop.fs.FilterFileSystem.getFileStatus(FilterFileSystem.java:425) at org.apache.hadoop.fs.FileSystem.exists(FileSystem.java:1414) at org.apache.hadoop.fs.FileUtil.checkDest(FileUtil.java:499) at org.apache.hadoop.fs.FileUtil.copy(FileUtil.java:351) 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.LocalFileSystem.copyFromLocalFile(LocalFileSystem.java:82) at org.apache.hadoop.fs.FileSystem.copyFromLocalFile(FileSystem.java:1884) at com.hellohadoop.FileOperator.Upload(FileOperator.java:48) at com.hellohadoop.FileOperator.main(FileOperator.java:23)
解决的办法是把Hadoop集群的hdfs-site.xml和core-site.xml两个配置文件复制到项目的bin目录下面,就可以正常运行了。