Skip to content
This repository was archived by the owner on Apr 5, 2022. It is now read-only.
This repository was archived by the owner on Apr 5, 2022. It is now read-only.

issue while reading data on hdfs from remote  #28

@alleyZ

Description

@alleyZ

I want to read the files on the remote HDFS,but there was an exception.

local ENV.

  • OS: windows 10
  • JDK 1.8
  • SHDP 2.4.0
  • hadoop 2.7.1

1. code

AbstractApplicationContext context = new ClassPathXmlApplicationContext(
                    "/application.xml", XmlUserApp.class);
            HdfsResourceLoader loader = context.getBean(HdfsResourceLoader.class);
            Resource resource = loader.getResource("hdfs://hd-23:6000/user/alleyz/hdfs.txt");
            System.out.println(resource.exists()); // true
            System.out.println(resource.lastModified()); // 1469696205365
            System.out.println(resource.isReadable()); // true
            System.out.println(resource.contentLength()); // 41
            System.out.println(resource.isOpen()); // true
            System.out.println(resource.isReadable()); // true
            File file = resource.getFile(); // throw exception

2. exception

java.lang.UnsupportedOperationException: Cannot resolve File object for HDFS Resource for [hdfs://hd-23:6000/user/alleyz/hdfs.txt]
    at org.springframework.data.hadoop.fs.HdfsResource.getFile(HdfsResource.java:160)
    at com.alleyz.spring.hadoop.hdfs.XmlHdfsApp.main(XmlHdfsApp.java:31)
    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:144)

How to solve it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions