xueyongfu 2018-10-17 11:52 采纳率: 0%
浏览 835
已采纳

客户端去操作hdfs时,出现异常

代码如下:


import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;


public class HDFSClient {
    public static void main(String[] args) throws Exception {
        // 1 获取文件系统
        Configuration configuration = new Configuration();

        // 配置在集群上运行
        configuration.set("fs.defaultFS", "hdfs://hadoop102:8020");
        FileSystem fs = FileSystem.get(configuration);


        // 2 把本地文件上传到文件系统中
        fs.copyFromLocalFile(new Path("e:/xiyou.txt"), new Path("/user/xiyou.txt"));

        // 3 关闭资源
        fs.close();
        //System.out.println("over");
    }
}

错误如下:

 Exception in thread "main" java.lang.ExceptionInInitializerError
    at org.apache.hadoop.util.StringUtils.<clinit>(StringUtils.java:80)
    at org.apache.hadoop.fs.FileSystem$Cache$Key.<init>(FileSystem.java:2806)
    at org.apache.hadoop.fs.FileSystem$Cache$Key.<init>(FileSystem.java:2802)
    at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2668)
    at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:371)
    at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:170)
    at com.root.hdfs.HDFSClient.main(HDFSClient.java:15)
Caused by: java.lang.StringIndexOutOfBoundsException: begin 0, end 3, length 2
    at java.base/java.lang.String.checkBoundsBeginEnd(String.java:3319)
    at java.base/java.lang.String.substring(String.java:1874)
    at org.apache.hadoop.util.Shell.<clinit>(Shell.java:50)
    ... 7 more

  • 写回答

2条回答 默认 最新

  • sf_www 2018-10-18 00:35
    关注

    https://issues.apache.org/jira/browse/HADOOP-14586
    是不是用了java9版本,java版本降低一下试试

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记