I have a project in Eclipse. When I run it from inside Eclipse, everything works just fine. However, when I run the Ant build script and execute the JAR either from the command line or using a batch script, I get a NullPointerException.
The NullPointerException in question is being thrown from a third-party JAR that I compiled from source. But, I doubt that's the problem - it works when I execute it inside Eclipse!
What could be causing this and how can I go about isolating the problem and correcting it?
Here is as much of the stack trace as I can show:
java.lang.NullPointerException
at java.io.FilterInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at java.io.DataInputStream.readUnsignedByte(Unknown Source)
at com.jhlabs.dbf.DBFFile.readHeader(DBFFile.java:129)
at com.jhlabs.dbf.DBFFile.<init>(DBFFile.java:76)
at com.jhlabs.map.shapefile.Shapefile.<init>(Shapefile.java:102)
at com.jhlabs.map.layer.ShapefileLayer.<init>(ShapefileLayer.java:62)
I checked the classpath - the third party JAR is indeed on the classpath. However, I expected that, as I would most likely get a NoClassDefFoundException if it was not and I tried to utilize the classes in the JAR.
I also checked the locations where I used a classloader, and they were not null and were correctly loading the proper files.