Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Hadoop, mail # user - Using hftp inside a servelet container


Copy link to this message
-
Using hftp inside a servelet container
madhu phatak 2012-03-21, 06:49
Hi,
 I am trying to access files hdfs through hftp.  When i run following code
from eclipse it works fine.
FsUrlStreamHandlerFactory factory                 new org.apache.hadoop.fs.FsUrlStreamHandlerFactory();
        java.net.URL.setURLStreamHandlerFactory(factory);

        URL hdfs = new URL("hdfs://<ip>/user/hadoop/<file>");
        BufferedReader in = new BufferedReader(
                new InputStreamReader(hdfs.openStream()));

        String inputLine;
        while ((inputLine = in.readLine()) != null)
            System.out.println(inputLine);
        in.close();

But when i run the same code from a JSP page(tomcat) I get following error

*java.lang.Error: factory already defined
        at java.net.URL.setURLStreamHandlerFactory(URL.java:1074)

*Is anyone tried to run hftp from tomcat?? Any ideas on how to resolve
this issue?
--
https://github.com/zinnia-phatak-dev/Nectar