NullPointerException on file.getAbsolutePath() but file.exists() returns true
<p>I'm writing an application where I'm using XPath to parse an xml file. Before i call DocumentBuilder's parse method, I create a File from the filename, and check if the file exists. This check returns true, but when i try to parse the file I get a nullpointerexception with this stacktrace: </p>

<pre><code>Exception in thread "main" java.lang.NullPointerException
    at java.io.WinNTFileSystem.normalize(Unknown Source)
    at java.io.WinNTFileSystem.getUserPath(Unknown Source)
    at java.io.WinNTFileSystem.resolve(Unknown Source)
    at java.io.File.getAbsolutePath(Unknown Source)
    at java.io.File.getAbsoluteFile(Unknown Source)
    at java.io.File.toURI(Unknown Source)
    at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
    at FileHandler.parseFile(OriginatorHandler.java:112)
    at Main.main(Main.java:58)
</code></pre>

<p>The file is in the same folder as I run the .jar application, and it has the right content. Here is my code:</p>

<pre><code>public Map&lt;String, List&lt;String&gt;&gt; parseFile(String fileName) {

    File file = new File(fileName);
    if (!file.exists()) {
        System.out.println("Couldn't find file [" + fileName + "]");
        System.exit(-1);
    }

    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = null;
    Document document = null;

    try {
        builder = factory.newDocumentBuilder();
        //This is where the exception is thrown 
        document = builder.parse(file);

        XPathFactory xPathFactory = XPathFactory.newInstance();
        XPath xPath = xPathFactory.newXPath();

        return getCaGroups(document, xPath);

    } catch (SAXException e) {
        e.printStackTrace();
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}
</code></pre>

<p>What can this error come frome? The file exists, it isn't null and is in the folder where I run the .jar file. What else could cause this problem? </p>