spring-attic / spring-hadoop-samples

Spring Hadoop Samples
Apache License 2.0
492 stars 466 forks source link

issue while reading data on hdfs from remote #28

Open alleyZ opened 8 years ago

alleyZ commented 8 years ago

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?

xjq95 commented 7 years ago

i got this error 2