You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-user@hadoop.apache.org by Ekta Agrawal <ek...@gmail.com> on 2014/06/06 12:19:38 UTC

hadoop java connection problem

Hi,

I am trying to read and write the file from HDFS.I am trying to read it and
display it on console. It runs without giving any error, warning or
exception but also it is not printing the data from file on console, My
file is already saved in hdfs , I can see it on user interface. I think
there is some problem with the path I have given, I am not sure as I am
connecting hadoop first time to java .I am using eclipse as IDE. Can
somebody look into this?

Code:
Path pt=new Path("hdfs://localhost:54310/user/hduser/project11/a.txt");
 FileSystem fs = FileSystem.get(new Configuration());
  BufferedReader br=new BufferedReader(new InputStreamReader(fs.open(pt)));
   String line;
                while (( line=br.readLine()) != null){
                                System.out.println(line);
                                line=br.readLine();
                        }

 if anybody has some idea of this. Please Share.

Regards,
Ekta

Re: hadoop java connection problem

Posted by Pralabh Kumar <pr...@gmail.com>.
you can extends Configured and implements Tool interface(in your main
class) ,which can take default parameter and put your code in run method and

FileSystem fs = FileSystem.get(this.getConf())


On Fri, Jun 6, 2014 at 4:41 PM, Vinod Patil <vi...@gmail.com> wrote:

> Also add hdfs-site.xml to the Configuration object. With this
> Configuration object, create a FileSystem object with this Configuration
> object before creating the Path.
>
>
> On Fri, Jun 6, 2014 at 4:21 PM, Raj K Singh <ra...@gmail.com> wrote:
>
>> have you tried to run it through "hadoop jar" instead of directly running
>> it through the eclipse. it seems problem with your path.
>>
>> try adding conf-site.xml using conf.addResource(new Path(Vars.HADOOP_HOME
>> +"/conf/core-site.xml")); before passing the conf reference to the FileSystem.get()
>> so that it can identify your filesystem correctly.
>>
>> ::::::::::::::::::::::::::::::::::::::::
>> Raj K Singh
>> http://in.linkedin.com/in/rajkrrsingh
>> http://www.rajkrrsingh.blogspot.com
>> Mobile  Tel: +91 (0)9899821370
>>
>>
>> On Fri, Jun 6, 2014 at 3:49 PM, Ekta Agrawal <ek...@gmail.com>
>> wrote:
>>
>>> Hi,
>>>
>>> I am trying to read and write the file from HDFS.I am trying to read it
>>> and display it on console. It runs without giving any error, warning or
>>> exception but also it is not printing the data from file on console, My
>>> file is already saved in hdfs , I can see it on user interface. I think
>>> there is some problem with the path I have given, I am not sure as I am
>>> connecting hadoop first time to java .I am using eclipse as IDE. Can
>>> somebody look into this?
>>>
>>> Code:
>>> Path pt=new Path("hdfs://localhost:54310/user/hduser/project11/a.txt");
>>>  FileSystem fs = FileSystem.get(new Configuration());
>>>   BufferedReader br=new BufferedReader(new
>>> InputStreamReader(fs.open(pt)));
>>>    String line;
>>>                 while (( line=br.readLine()) != null){
>>>                                 System.out.println(line);
>>>                                 line=br.readLine();
>>>                         }
>>>
>>>  if anybody has some idea of this. Please Share.
>>>
>>> Regards,
>>> Ekta
>>>
>>
>>
>

Re: hadoop java connection problem

Posted by Pralabh Kumar <pr...@gmail.com>.
you can extends Configured and implements Tool interface(in your main
class) ,which can take default parameter and put your code in run method and

FileSystem fs = FileSystem.get(this.getConf())


On Fri, Jun 6, 2014 at 4:41 PM, Vinod Patil <vi...@gmail.com> wrote:

> Also add hdfs-site.xml to the Configuration object. With this
> Configuration object, create a FileSystem object with this Configuration
> object before creating the Path.
>
>
> On Fri, Jun 6, 2014 at 4:21 PM, Raj K Singh <ra...@gmail.com> wrote:
>
>> have you tried to run it through "hadoop jar" instead of directly running
>> it through the eclipse. it seems problem with your path.
>>
>> try adding conf-site.xml using conf.addResource(new Path(Vars.HADOOP_HOME
>> +"/conf/core-site.xml")); before passing the conf reference to the FileSystem.get()
>> so that it can identify your filesystem correctly.
>>
>> ::::::::::::::::::::::::::::::::::::::::
>> Raj K Singh
>> http://in.linkedin.com/in/rajkrrsingh
>> http://www.rajkrrsingh.blogspot.com
>> Mobile  Tel: +91 (0)9899821370
>>
>>
>> On Fri, Jun 6, 2014 at 3:49 PM, Ekta Agrawal <ek...@gmail.com>
>> wrote:
>>
>>> Hi,
>>>
>>> I am trying to read and write the file from HDFS.I am trying to read it
>>> and display it on console. It runs without giving any error, warning or
>>> exception but also it is not printing the data from file on console, My
>>> file is already saved in hdfs , I can see it on user interface. I think
>>> there is some problem with the path I have given, I am not sure as I am
>>> connecting hadoop first time to java .I am using eclipse as IDE. Can
>>> somebody look into this?
>>>
>>> Code:
>>> Path pt=new Path("hdfs://localhost:54310/user/hduser/project11/a.txt");
>>>  FileSystem fs = FileSystem.get(new Configuration());
>>>   BufferedReader br=new BufferedReader(new
>>> InputStreamReader(fs.open(pt)));
>>>    String line;
>>>                 while (( line=br.readLine()) != null){
>>>                                 System.out.println(line);
>>>                                 line=br.readLine();
>>>                         }
>>>
>>>  if anybody has some idea of this. Please Share.
>>>
>>> Regards,
>>> Ekta
>>>
>>
>>
>

Re: hadoop java connection problem

Posted by Pralabh Kumar <pr...@gmail.com>.
you can extends Configured and implements Tool interface(in your main
class) ,which can take default parameter and put your code in run method and

FileSystem fs = FileSystem.get(this.getConf())


On Fri, Jun 6, 2014 at 4:41 PM, Vinod Patil <vi...@gmail.com> wrote:

> Also add hdfs-site.xml to the Configuration object. With this
> Configuration object, create a FileSystem object with this Configuration
> object before creating the Path.
>
>
> On Fri, Jun 6, 2014 at 4:21 PM, Raj K Singh <ra...@gmail.com> wrote:
>
>> have you tried to run it through "hadoop jar" instead of directly running
>> it through the eclipse. it seems problem with your path.
>>
>> try adding conf-site.xml using conf.addResource(new Path(Vars.HADOOP_HOME
>> +"/conf/core-site.xml")); before passing the conf reference to the FileSystem.get()
>> so that it can identify your filesystem correctly.
>>
>> ::::::::::::::::::::::::::::::::::::::::
>> Raj K Singh
>> http://in.linkedin.com/in/rajkrrsingh
>> http://www.rajkrrsingh.blogspot.com
>> Mobile  Tel: +91 (0)9899821370
>>
>>
>> On Fri, Jun 6, 2014 at 3:49 PM, Ekta Agrawal <ek...@gmail.com>
>> wrote:
>>
>>> Hi,
>>>
>>> I am trying to read and write the file from HDFS.I am trying to read it
>>> and display it on console. It runs without giving any error, warning or
>>> exception but also it is not printing the data from file on console, My
>>> file is already saved in hdfs , I can see it on user interface. I think
>>> there is some problem with the path I have given, I am not sure as I am
>>> connecting hadoop first time to java .I am using eclipse as IDE. Can
>>> somebody look into this?
>>>
>>> Code:
>>> Path pt=new Path("hdfs://localhost:54310/user/hduser/project11/a.txt");
>>>  FileSystem fs = FileSystem.get(new Configuration());
>>>   BufferedReader br=new BufferedReader(new
>>> InputStreamReader(fs.open(pt)));
>>>    String line;
>>>                 while (( line=br.readLine()) != null){
>>>                                 System.out.println(line);
>>>                                 line=br.readLine();
>>>                         }
>>>
>>>  if anybody has some idea of this. Please Share.
>>>
>>> Regards,
>>> Ekta
>>>
>>
>>
>

Re: hadoop java connection problem

Posted by Ekta Agrawal <ek...@gmail.com>.
Hi ...Thanks a lot guys....

I have added conf.addResource(new Path(Vars.HADOOP_HOME
+"/conf/core-site.xml"));

and it worked....:)..yippieee


On Fri, Jun 6, 2014 at 4:41 PM, Vinod Patil <vi...@gmail.com> wrote:

> Also add hdfs-site.xml to the Configuration object. With this
> Configuration object, create a FileSystem object with this Configuration
> object before creating the Path.
>
>
> On Fri, Jun 6, 2014 at 4:21 PM, Raj K Singh <ra...@gmail.com> wrote:
>
>> have you tried to run it through "hadoop jar" instead of directly running
>> it through the eclipse. it seems problem with your path.
>>
>> try adding conf-site.xml using conf.addResource(new Path(Vars.HADOOP_HOME
>> +"/conf/core-site.xml")); before passing the conf reference to the FileSystem.get()
>> so that it can identify your filesystem correctly.
>>
>> ::::::::::::::::::::::::::::::::::::::::
>> Raj K Singh
>> http://in.linkedin.com/in/rajkrrsingh
>> http://www.rajkrrsingh.blogspot.com
>> Mobile  Tel: +91 (0)9899821370
>>
>>
>> On Fri, Jun 6, 2014 at 3:49 PM, Ekta Agrawal <ek...@gmail.com>
>> wrote:
>>
>>> Hi,
>>>
>>> I am trying to read and write the file from HDFS.I am trying to read it
>>> and display it on console. It runs without giving any error, warning or
>>> exception but also it is not printing the data from file on console, My
>>> file is already saved in hdfs , I can see it on user interface. I think
>>> there is some problem with the path I have given, I am not sure as I am
>>> connecting hadoop first time to java .I am using eclipse as IDE. Can
>>> somebody look into this?
>>>
>>> Code:
>>> Path pt=new Path("hdfs://localhost:54310/user/hduser/project11/a.txt");
>>>  FileSystem fs = FileSystem.get(new Configuration());
>>>   BufferedReader br=new BufferedReader(new
>>> InputStreamReader(fs.open(pt)));
>>>    String line;
>>>                 while (( line=br.readLine()) != null){
>>>                                 System.out.println(line);
>>>                                 line=br.readLine();
>>>                         }
>>>
>>>  if anybody has some idea of this. Please Share.
>>>
>>> Regards,
>>> Ekta
>>>
>>
>>
>

Re: hadoop java connection problem

Posted by Ekta Agrawal <ek...@gmail.com>.
Hi ...Thanks a lot guys....

I have added conf.addResource(new Path(Vars.HADOOP_HOME
+"/conf/core-site.xml"));

and it worked....:)..yippieee


On Fri, Jun 6, 2014 at 4:41 PM, Vinod Patil <vi...@gmail.com> wrote:

> Also add hdfs-site.xml to the Configuration object. With this
> Configuration object, create a FileSystem object with this Configuration
> object before creating the Path.
>
>
> On Fri, Jun 6, 2014 at 4:21 PM, Raj K Singh <ra...@gmail.com> wrote:
>
>> have you tried to run it through "hadoop jar" instead of directly running
>> it through the eclipse. it seems problem with your path.
>>
>> try adding conf-site.xml using conf.addResource(new Path(Vars.HADOOP_HOME
>> +"/conf/core-site.xml")); before passing the conf reference to the FileSystem.get()
>> so that it can identify your filesystem correctly.
>>
>> ::::::::::::::::::::::::::::::::::::::::
>> Raj K Singh
>> http://in.linkedin.com/in/rajkrrsingh
>> http://www.rajkrrsingh.blogspot.com
>> Mobile  Tel: +91 (0)9899821370
>>
>>
>> On Fri, Jun 6, 2014 at 3:49 PM, Ekta Agrawal <ek...@gmail.com>
>> wrote:
>>
>>> Hi,
>>>
>>> I am trying to read and write the file from HDFS.I am trying to read it
>>> and display it on console. It runs without giving any error, warning or
>>> exception but also it is not printing the data from file on console, My
>>> file is already saved in hdfs , I can see it on user interface. I think
>>> there is some problem with the path I have given, I am not sure as I am
>>> connecting hadoop first time to java .I am using eclipse as IDE. Can
>>> somebody look into this?
>>>
>>> Code:
>>> Path pt=new Path("hdfs://localhost:54310/user/hduser/project11/a.txt");
>>>  FileSystem fs = FileSystem.get(new Configuration());
>>>   BufferedReader br=new BufferedReader(new
>>> InputStreamReader(fs.open(pt)));
>>>    String line;
>>>                 while (( line=br.readLine()) != null){
>>>                                 System.out.println(line);
>>>                                 line=br.readLine();
>>>                         }
>>>
>>>  if anybody has some idea of this. Please Share.
>>>
>>> Regards,
>>> Ekta
>>>
>>
>>
>

Re: hadoop java connection problem

Posted by Ekta Agrawal <ek...@gmail.com>.
Hi ...Thanks a lot guys....

I have added conf.addResource(new Path(Vars.HADOOP_HOME
+"/conf/core-site.xml"));

and it worked....:)..yippieee


On Fri, Jun 6, 2014 at 4:41 PM, Vinod Patil <vi...@gmail.com> wrote:

> Also add hdfs-site.xml to the Configuration object. With this
> Configuration object, create a FileSystem object with this Configuration
> object before creating the Path.
>
>
> On Fri, Jun 6, 2014 at 4:21 PM, Raj K Singh <ra...@gmail.com> wrote:
>
>> have you tried to run it through "hadoop jar" instead of directly running
>> it through the eclipse. it seems problem with your path.
>>
>> try adding conf-site.xml using conf.addResource(new Path(Vars.HADOOP_HOME
>> +"/conf/core-site.xml")); before passing the conf reference to the FileSystem.get()
>> so that it can identify your filesystem correctly.
>>
>> ::::::::::::::::::::::::::::::::::::::::
>> Raj K Singh
>> http://in.linkedin.com/in/rajkrrsingh
>> http://www.rajkrrsingh.blogspot.com
>> Mobile  Tel: +91 (0)9899821370
>>
>>
>> On Fri, Jun 6, 2014 at 3:49 PM, Ekta Agrawal <ek...@gmail.com>
>> wrote:
>>
>>> Hi,
>>>
>>> I am trying to read and write the file from HDFS.I am trying to read it
>>> and display it on console. It runs without giving any error, warning or
>>> exception but also it is not printing the data from file on console, My
>>> file is already saved in hdfs , I can see it on user interface. I think
>>> there is some problem with the path I have given, I am not sure as I am
>>> connecting hadoop first time to java .I am using eclipse as IDE. Can
>>> somebody look into this?
>>>
>>> Code:
>>> Path pt=new Path("hdfs://localhost:54310/user/hduser/project11/a.txt");
>>>  FileSystem fs = FileSystem.get(new Configuration());
>>>   BufferedReader br=new BufferedReader(new
>>> InputStreamReader(fs.open(pt)));
>>>    String line;
>>>                 while (( line=br.readLine()) != null){
>>>                                 System.out.println(line);
>>>                                 line=br.readLine();
>>>                         }
>>>
>>>  if anybody has some idea of this. Please Share.
>>>
>>> Regards,
>>> Ekta
>>>
>>
>>
>

Re: hadoop java connection problem

Posted by Pralabh Kumar <pr...@gmail.com>.
you can extends Configured and implements Tool interface(in your main
class) ,which can take default parameter and put your code in run method and

FileSystem fs = FileSystem.get(this.getConf())


On Fri, Jun 6, 2014 at 4:41 PM, Vinod Patil <vi...@gmail.com> wrote:

> Also add hdfs-site.xml to the Configuration object. With this
> Configuration object, create a FileSystem object with this Configuration
> object before creating the Path.
>
>
> On Fri, Jun 6, 2014 at 4:21 PM, Raj K Singh <ra...@gmail.com> wrote:
>
>> have you tried to run it through "hadoop jar" instead of directly running
>> it through the eclipse. it seems problem with your path.
>>
>> try adding conf-site.xml using conf.addResource(new Path(Vars.HADOOP_HOME
>> +"/conf/core-site.xml")); before passing the conf reference to the FileSystem.get()
>> so that it can identify your filesystem correctly.
>>
>> ::::::::::::::::::::::::::::::::::::::::
>> Raj K Singh
>> http://in.linkedin.com/in/rajkrrsingh
>> http://www.rajkrrsingh.blogspot.com
>> Mobile  Tel: +91 (0)9899821370
>>
>>
>> On Fri, Jun 6, 2014 at 3:49 PM, Ekta Agrawal <ek...@gmail.com>
>> wrote:
>>
>>> Hi,
>>>
>>> I am trying to read and write the file from HDFS.I am trying to read it
>>> and display it on console. It runs without giving any error, warning or
>>> exception but also it is not printing the data from file on console, My
>>> file is already saved in hdfs , I can see it on user interface. I think
>>> there is some problem with the path I have given, I am not sure as I am
>>> connecting hadoop first time to java .I am using eclipse as IDE. Can
>>> somebody look into this?
>>>
>>> Code:
>>> Path pt=new Path("hdfs://localhost:54310/user/hduser/project11/a.txt");
>>>  FileSystem fs = FileSystem.get(new Configuration());
>>>   BufferedReader br=new BufferedReader(new
>>> InputStreamReader(fs.open(pt)));
>>>    String line;
>>>                 while (( line=br.readLine()) != null){
>>>                                 System.out.println(line);
>>>                                 line=br.readLine();
>>>                         }
>>>
>>>  if anybody has some idea of this. Please Share.
>>>
>>> Regards,
>>> Ekta
>>>
>>
>>
>

Re: hadoop java connection problem

Posted by Ekta Agrawal <ek...@gmail.com>.
Hi ...Thanks a lot guys....

I have added conf.addResource(new Path(Vars.HADOOP_HOME
+"/conf/core-site.xml"));

and it worked....:)..yippieee


On Fri, Jun 6, 2014 at 4:41 PM, Vinod Patil <vi...@gmail.com> wrote:

> Also add hdfs-site.xml to the Configuration object. With this
> Configuration object, create a FileSystem object with this Configuration
> object before creating the Path.
>
>
> On Fri, Jun 6, 2014 at 4:21 PM, Raj K Singh <ra...@gmail.com> wrote:
>
>> have you tried to run it through "hadoop jar" instead of directly running
>> it through the eclipse. it seems problem with your path.
>>
>> try adding conf-site.xml using conf.addResource(new Path(Vars.HADOOP_HOME
>> +"/conf/core-site.xml")); before passing the conf reference to the FileSystem.get()
>> so that it can identify your filesystem correctly.
>>
>> ::::::::::::::::::::::::::::::::::::::::
>> Raj K Singh
>> http://in.linkedin.com/in/rajkrrsingh
>> http://www.rajkrrsingh.blogspot.com
>> Mobile  Tel: +91 (0)9899821370
>>
>>
>> On Fri, Jun 6, 2014 at 3:49 PM, Ekta Agrawal <ek...@gmail.com>
>> wrote:
>>
>>> Hi,
>>>
>>> I am trying to read and write the file from HDFS.I am trying to read it
>>> and display it on console. It runs without giving any error, warning or
>>> exception but also it is not printing the data from file on console, My
>>> file is already saved in hdfs , I can see it on user interface. I think
>>> there is some problem with the path I have given, I am not sure as I am
>>> connecting hadoop first time to java .I am using eclipse as IDE. Can
>>> somebody look into this?
>>>
>>> Code:
>>> Path pt=new Path("hdfs://localhost:54310/user/hduser/project11/a.txt");
>>>  FileSystem fs = FileSystem.get(new Configuration());
>>>   BufferedReader br=new BufferedReader(new
>>> InputStreamReader(fs.open(pt)));
>>>    String line;
>>>                 while (( line=br.readLine()) != null){
>>>                                 System.out.println(line);
>>>                                 line=br.readLine();
>>>                         }
>>>
>>>  if anybody has some idea of this. Please Share.
>>>
>>> Regards,
>>> Ekta
>>>
>>
>>
>

Re: hadoop java connection problem

Posted by Vinod Patil <vi...@gmail.com>.
Also add hdfs-site.xml to the Configuration object. With this Configuration
object, create a FileSystem object with this Configuration object before
creating the Path.


On Fri, Jun 6, 2014 at 4:21 PM, Raj K Singh <ra...@gmail.com> wrote:

> have you tried to run it through "hadoop jar" instead of directly running
> it through the eclipse. it seems problem with your path.
>
> try adding conf-site.xml using conf.addResource(new Path(Vars.HADOOP_HOME
> +"/conf/core-site.xml")); before passing the conf reference to the FileSystem.get()
> so that it can identify your filesystem correctly.
>
> ::::::::::::::::::::::::::::::::::::::::
> Raj K Singh
> http://in.linkedin.com/in/rajkrrsingh
> http://www.rajkrrsingh.blogspot.com
> Mobile  Tel: +91 (0)9899821370
>
>
> On Fri, Jun 6, 2014 at 3:49 PM, Ekta Agrawal <ek...@gmail.com>
> wrote:
>
>> Hi,
>>
>> I am trying to read and write the file from HDFS.I am trying to read it
>> and display it on console. It runs without giving any error, warning or
>> exception but also it is not printing the data from file on console, My
>> file is already saved in hdfs , I can see it on user interface. I think
>> there is some problem with the path I have given, I am not sure as I am
>> connecting hadoop first time to java .I am using eclipse as IDE. Can
>> somebody look into this?
>>
>> Code:
>> Path pt=new Path("hdfs://localhost:54310/user/hduser/project11/a.txt");
>>  FileSystem fs = FileSystem.get(new Configuration());
>>   BufferedReader br=new BufferedReader(new
>> InputStreamReader(fs.open(pt)));
>>    String line;
>>                 while (( line=br.readLine()) != null){
>>                                 System.out.println(line);
>>                                 line=br.readLine();
>>                         }
>>
>>  if anybody has some idea of this. Please Share.
>>
>> Regards,
>> Ekta
>>
>
>

Re: hadoop java connection problem

Posted by Vinod Patil <vi...@gmail.com>.
Also add hdfs-site.xml to the Configuration object. With this Configuration
object, create a FileSystem object with this Configuration object before
creating the Path.


On Fri, Jun 6, 2014 at 4:21 PM, Raj K Singh <ra...@gmail.com> wrote:

> have you tried to run it through "hadoop jar" instead of directly running
> it through the eclipse. it seems problem with your path.
>
> try adding conf-site.xml using conf.addResource(new Path(Vars.HADOOP_HOME
> +"/conf/core-site.xml")); before passing the conf reference to the FileSystem.get()
> so that it can identify your filesystem correctly.
>
> ::::::::::::::::::::::::::::::::::::::::
> Raj K Singh
> http://in.linkedin.com/in/rajkrrsingh
> http://www.rajkrrsingh.blogspot.com
> Mobile  Tel: +91 (0)9899821370
>
>
> On Fri, Jun 6, 2014 at 3:49 PM, Ekta Agrawal <ek...@gmail.com>
> wrote:
>
>> Hi,
>>
>> I am trying to read and write the file from HDFS.I am trying to read it
>> and display it on console. It runs without giving any error, warning or
>> exception but also it is not printing the data from file on console, My
>> file is already saved in hdfs , I can see it on user interface. I think
>> there is some problem with the path I have given, I am not sure as I am
>> connecting hadoop first time to java .I am using eclipse as IDE. Can
>> somebody look into this?
>>
>> Code:
>> Path pt=new Path("hdfs://localhost:54310/user/hduser/project11/a.txt");
>>  FileSystem fs = FileSystem.get(new Configuration());
>>   BufferedReader br=new BufferedReader(new
>> InputStreamReader(fs.open(pt)));
>>    String line;
>>                 while (( line=br.readLine()) != null){
>>                                 System.out.println(line);
>>                                 line=br.readLine();
>>                         }
>>
>>  if anybody has some idea of this. Please Share.
>>
>> Regards,
>> Ekta
>>
>
>

Re: hadoop java connection problem

Posted by Vinod Patil <vi...@gmail.com>.
Also add hdfs-site.xml to the Configuration object. With this Configuration
object, create a FileSystem object with this Configuration object before
creating the Path.


On Fri, Jun 6, 2014 at 4:21 PM, Raj K Singh <ra...@gmail.com> wrote:

> have you tried to run it through "hadoop jar" instead of directly running
> it through the eclipse. it seems problem with your path.
>
> try adding conf-site.xml using conf.addResource(new Path(Vars.HADOOP_HOME
> +"/conf/core-site.xml")); before passing the conf reference to the FileSystem.get()
> so that it can identify your filesystem correctly.
>
> ::::::::::::::::::::::::::::::::::::::::
> Raj K Singh
> http://in.linkedin.com/in/rajkrrsingh
> http://www.rajkrrsingh.blogspot.com
> Mobile  Tel: +91 (0)9899821370
>
>
> On Fri, Jun 6, 2014 at 3:49 PM, Ekta Agrawal <ek...@gmail.com>
> wrote:
>
>> Hi,
>>
>> I am trying to read and write the file from HDFS.I am trying to read it
>> and display it on console. It runs without giving any error, warning or
>> exception but also it is not printing the data from file on console, My
>> file is already saved in hdfs , I can see it on user interface. I think
>> there is some problem with the path I have given, I am not sure as I am
>> connecting hadoop first time to java .I am using eclipse as IDE. Can
>> somebody look into this?
>>
>> Code:
>> Path pt=new Path("hdfs://localhost:54310/user/hduser/project11/a.txt");
>>  FileSystem fs = FileSystem.get(new Configuration());
>>   BufferedReader br=new BufferedReader(new
>> InputStreamReader(fs.open(pt)));
>>    String line;
>>                 while (( line=br.readLine()) != null){
>>                                 System.out.println(line);
>>                                 line=br.readLine();
>>                         }
>>
>>  if anybody has some idea of this. Please Share.
>>
>> Regards,
>> Ekta
>>
>
>

Re: hadoop java connection problem

Posted by Vinod Patil <vi...@gmail.com>.
Also add hdfs-site.xml to the Configuration object. With this Configuration
object, create a FileSystem object with this Configuration object before
creating the Path.


On Fri, Jun 6, 2014 at 4:21 PM, Raj K Singh <ra...@gmail.com> wrote:

> have you tried to run it through "hadoop jar" instead of directly running
> it through the eclipse. it seems problem with your path.
>
> try adding conf-site.xml using conf.addResource(new Path(Vars.HADOOP_HOME
> +"/conf/core-site.xml")); before passing the conf reference to the FileSystem.get()
> so that it can identify your filesystem correctly.
>
> ::::::::::::::::::::::::::::::::::::::::
> Raj K Singh
> http://in.linkedin.com/in/rajkrrsingh
> http://www.rajkrrsingh.blogspot.com
> Mobile  Tel: +91 (0)9899821370
>
>
> On Fri, Jun 6, 2014 at 3:49 PM, Ekta Agrawal <ek...@gmail.com>
> wrote:
>
>> Hi,
>>
>> I am trying to read and write the file from HDFS.I am trying to read it
>> and display it on console. It runs without giving any error, warning or
>> exception but also it is not printing the data from file on console, My
>> file is already saved in hdfs , I can see it on user interface. I think
>> there is some problem with the path I have given, I am not sure as I am
>> connecting hadoop first time to java .I am using eclipse as IDE. Can
>> somebody look into this?
>>
>> Code:
>> Path pt=new Path("hdfs://localhost:54310/user/hduser/project11/a.txt");
>>  FileSystem fs = FileSystem.get(new Configuration());
>>   BufferedReader br=new BufferedReader(new
>> InputStreamReader(fs.open(pt)));
>>    String line;
>>                 while (( line=br.readLine()) != null){
>>                                 System.out.println(line);
>>                                 line=br.readLine();
>>                         }
>>
>>  if anybody has some idea of this. Please Share.
>>
>> Regards,
>> Ekta
>>
>
>

Re: hadoop java connection problem

Posted by Raj K Singh <ra...@gmail.com>.
have you tried to run it through "hadoop jar" instead of directly running
it through the eclipse. it seems problem with your path.

try adding conf-site.xml using conf.addResource(new Path(Vars.HADOOP_HOME
+"/conf/core-site.xml")); before passing the conf reference to the
FileSystem.get()
so that it can identify your filesystem correctly.

::::::::::::::::::::::::::::::::::::::::
Raj K Singh
http://in.linkedin.com/in/rajkrrsingh
http://www.rajkrrsingh.blogspot.com
Mobile  Tel: +91 (0)9899821370


On Fri, Jun 6, 2014 at 3:49 PM, Ekta Agrawal <ek...@gmail.com>
wrote:

> Hi,
>
> I am trying to read and write the file from HDFS.I am trying to read it
> and display it on console. It runs without giving any error, warning or
> exception but also it is not printing the data from file on console, My
> file is already saved in hdfs , I can see it on user interface. I think
> there is some problem with the path I have given, I am not sure as I am
> connecting hadoop first time to java .I am using eclipse as IDE. Can
> somebody look into this?
>
> Code:
> Path pt=new Path("hdfs://localhost:54310/user/hduser/project11/a.txt");
>  FileSystem fs = FileSystem.get(new Configuration());
>   BufferedReader br=new BufferedReader(new InputStreamReader(fs.open(pt)));
>    String line;
>                 while (( line=br.readLine()) != null){
>                                 System.out.println(line);
>                                 line=br.readLine();
>                         }
>
>  if anybody has some idea of this. Please Share.
>
> Regards,
> Ekta
>

Re: hadoop java connection problem

Posted by Raj K Singh <ra...@gmail.com>.
have you tried to run it through "hadoop jar" instead of directly running
it through the eclipse. it seems problem with your path.

try adding conf-site.xml using conf.addResource(new Path(Vars.HADOOP_HOME
+"/conf/core-site.xml")); before passing the conf reference to the
FileSystem.get()
so that it can identify your filesystem correctly.

::::::::::::::::::::::::::::::::::::::::
Raj K Singh
http://in.linkedin.com/in/rajkrrsingh
http://www.rajkrrsingh.blogspot.com
Mobile  Tel: +91 (0)9899821370


On Fri, Jun 6, 2014 at 3:49 PM, Ekta Agrawal <ek...@gmail.com>
wrote:

> Hi,
>
> I am trying to read and write the file from HDFS.I am trying to read it
> and display it on console. It runs without giving any error, warning or
> exception but also it is not printing the data from file on console, My
> file is already saved in hdfs , I can see it on user interface. I think
> there is some problem with the path I have given, I am not sure as I am
> connecting hadoop first time to java .I am using eclipse as IDE. Can
> somebody look into this?
>
> Code:
> Path pt=new Path("hdfs://localhost:54310/user/hduser/project11/a.txt");
>  FileSystem fs = FileSystem.get(new Configuration());
>   BufferedReader br=new BufferedReader(new InputStreamReader(fs.open(pt)));
>    String line;
>                 while (( line=br.readLine()) != null){
>                                 System.out.println(line);
>                                 line=br.readLine();
>                         }
>
>  if anybody has some idea of this. Please Share.
>
> Regards,
> Ekta
>

Re: hadoop java connection problem

Posted by Raj K Singh <ra...@gmail.com>.
have you tried to run it through "hadoop jar" instead of directly running
it through the eclipse. it seems problem with your path.

try adding conf-site.xml using conf.addResource(new Path(Vars.HADOOP_HOME
+"/conf/core-site.xml")); before passing the conf reference to the
FileSystem.get()
so that it can identify your filesystem correctly.

::::::::::::::::::::::::::::::::::::::::
Raj K Singh
http://in.linkedin.com/in/rajkrrsingh
http://www.rajkrrsingh.blogspot.com
Mobile  Tel: +91 (0)9899821370


On Fri, Jun 6, 2014 at 3:49 PM, Ekta Agrawal <ek...@gmail.com>
wrote:

> Hi,
>
> I am trying to read and write the file from HDFS.I am trying to read it
> and display it on console. It runs without giving any error, warning or
> exception but also it is not printing the data from file on console, My
> file is already saved in hdfs , I can see it on user interface. I think
> there is some problem with the path I have given, I am not sure as I am
> connecting hadoop first time to java .I am using eclipse as IDE. Can
> somebody look into this?
>
> Code:
> Path pt=new Path("hdfs://localhost:54310/user/hduser/project11/a.txt");
>  FileSystem fs = FileSystem.get(new Configuration());
>   BufferedReader br=new BufferedReader(new InputStreamReader(fs.open(pt)));
>    String line;
>                 while (( line=br.readLine()) != null){
>                                 System.out.println(line);
>                                 line=br.readLine();
>                         }
>
>  if anybody has some idea of this. Please Share.
>
> Regards,
> Ekta
>

Re: hadoop java connection problem

Posted by Raj K Singh <ra...@gmail.com>.
have you tried to run it through "hadoop jar" instead of directly running
it through the eclipse. it seems problem with your path.

try adding conf-site.xml using conf.addResource(new Path(Vars.HADOOP_HOME
+"/conf/core-site.xml")); before passing the conf reference to the
FileSystem.get()
so that it can identify your filesystem correctly.

::::::::::::::::::::::::::::::::::::::::
Raj K Singh
http://in.linkedin.com/in/rajkrrsingh
http://www.rajkrrsingh.blogspot.com
Mobile  Tel: +91 (0)9899821370


On Fri, Jun 6, 2014 at 3:49 PM, Ekta Agrawal <ek...@gmail.com>
wrote:

> Hi,
>
> I am trying to read and write the file from HDFS.I am trying to read it
> and display it on console. It runs without giving any error, warning or
> exception but also it is not printing the data from file on console, My
> file is already saved in hdfs , I can see it on user interface. I think
> there is some problem with the path I have given, I am not sure as I am
> connecting hadoop first time to java .I am using eclipse as IDE. Can
> somebody look into this?
>
> Code:
> Path pt=new Path("hdfs://localhost:54310/user/hduser/project11/a.txt");
>  FileSystem fs = FileSystem.get(new Configuration());
>   BufferedReader br=new BufferedReader(new InputStreamReader(fs.open(pt)));
>    String line;
>                 while (( line=br.readLine()) != null){
>                                 System.out.println(line);
>                                 line=br.readLine();
>                         }
>
>  if anybody has some idea of this. Please Share.
>
> Regards,
> Ekta
>