0

I am trying to read a har file and the readHarFile is throwing a null pointer exception. here is the sample code that i am trying to use:

public class readhar{
  public static void main(String [] args) throws exception{
    File f = new File ("file path");
    HarFileReader r = new HarFileReader();
    HarLog log = r.readHarFile(f);
    System.out.println(log);
  }
}

Exception is:

Exception in thread "main" java.lang.NullPointerException at 
edu.umass.cs.benchlab.har.HarLog.<init>(HarLog.java:134) at 
edu.umass.cs.benchlab.har.tools.HarFileReader.readHarFile(HarFileReader.java:116‌​) at 
edu.umass.cs.benchlab.har.tools.HarFileReader.readHarFile(HarFileReader.java:89) at 
readHar.main(readHar.java:18) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native  Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav‌​a:43)
madth3
  • 7,001
  • 11
  • 45
  • 69
satheesh
  • 11
  • 4
  • Does it compile? Does not look so. And could you also put the stack trace? – Audrius Meskauskas Jan 17 '13 at 19:44
  • compilation didn't throw any errors. – satheesh Jan 17 '13 at 19:58
  • Exception in thread "main" java.lang.NullPointerException at edu.umass.cs.benchlab.har.HarLog.(HarLog.java:134) at edu.umass.cs.benchlab.har.tools.HarFileReader.readHarFile(HarFileReader.java:116) at edu.umass.cs.benchlab.har.tools.HarFileReader.readHarFile(HarFileReader.java:89) at readHar.main(readHar.java:18) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) – satheesh Jan 17 '13 at 19:59
  • 2
    did you check that the file you're trying to read actually exists? try adding `System.out.println("exists" + f.exists());` after instantating the new file. – Nathan Hughes Jan 17 '13 at 20:45
  • its returning true. also i checked manually in the path and the file exists. – satheesh Jan 17 '13 at 21:37
  • Fixed that issue by adding harlib-jackson-1.1final.jar – satheesh Jan 23 '13 at 02:28

0 Answers0