hadoop-common-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elton sky <eltonsky9...@gmail.com>
Subject Could not get FileSystem obj, get java.lang.NullPointerException !!
Date Thu, 24 Jun 2010 06:42:34 GMT
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!

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message