Thanks for reply,
On Thu, Jun 24, 2010 at 7:35 PM, Steve Loughran <ste...@apache.org> wrote: > elton sky wrote: > >> Hi, >> I am new to hadoop programming. >> > > > OK. First hint of advice: don't spam the dev lists with user problems, you > will only get ignored in both mailing lists. > > Get ur advice :) > > I am trying to copy a local file to HDFS. My > > . >> 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. >> > > This is time to reach for your debugger. We don't know why it is null, > probably something odd with how your configuration is booted up. Follow the > constructor. > > The other tactic, and the one I do first, is search for that stack trace on > the web and on https://issues.apache.org/jira/ That way, if someone has > hit the same problem as you, you'll find the solution > I mistakenly put : static { URL.setURLStreamHandlerFactory(new FsUrlStreamHandlerFactory()); } on the top of the code, which makes the exception. I commented out and it just works. I have no idea why this matters?