Hi Elton,

  Can you mention the hadoop version? Also, can you double-check if you set
"fs.default.name" property correctly in conf/hdfs-site.xml?

-Chaitanya.

On Thu, Jun 24, 2010 at 12:12 PM, elton sky <eltonsky9...@gmail.com> wrote:

> Hi,
> I am new to hadoop programming. I am trying to copy a local file to HDFS.
> My
> code snippet is:
> .
> .
>        Configuration conf = new Configuration();
>
>        InputStream in=null;
>        OutputStream out = null;
>        try {
>            in = new BufferedInputStream(new FileInputStream(src));
>
>            FileSystem fs = FileSystem.get(URI.create(dest), conf);
> *//line:42.
> Exception here*
>
>            if(fs == null)
>                System.out.println("fs is null");
>            else
>                System.out.println("fs is not null");
>
>            out = fs.create(new Path(dest), true);
>            IOUtils.copyBytes(in, out, conf, true);
>
>            System.out.println(dest +" is created successfully.");
>
>          } catch (IOException e) {
>            IOUtils.closeStream(out);
>            IOUtils.closeStream(in);
>            throw e;
>          }
> .
> .
> and when I run it, I got exception:
> Exception in thread "main" java.lang.NullPointerException
>
>        at org.apache.hadoop.conf.Configuration.get(Configuration.java:436)
>
>        at
> org.apache.hadoop.fs.FileSystem.getDefaultUri(FileSystem.java:103)
>        at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:95)
>
>        at HDFSFile.create(HDFSFile.java:42)
>
>        at HDFSFile.main(HDFSFile.java:130)
>
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
>        at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>        at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>        at
> java.lang.reflect.Method.invoke(Method.java:616)
>
>        at org.apache.hadoop.util.RunJar.main(RunJar.java:156
>
> After dug into source code of hdfs, I found the problem happens at
> "Configuration.getProps()". The value of getProps() is null and, obviously,
> it shouldn't be.
>
> I couldn't figure out why this happen. Please help me out here.
> Appreciate!
>

Reply via email to