Help save net neutrality! Learn more.
Close

#52 XMLReader.parse() throws NullPointerException when base file

closed-invalid
nobody
None
5
2014-08-25
2003-08-13
m.hilpert
No

This is a really strange error:

I process an XML file and it works fine - as long as I
type the file name of
the XML file with the correct capitalized letters! E.g. I
have a XML
file "RVT_0306.XML". I read the file and also check if the
file exists via

File = new File("RVT_0306.XML");
if (file.exists()) {
...
)

But if i load the file e.g. with a small 't':

File = new File("RVt_0306.XML");

this exception occurs. On the other hand, a changed
letters of the suffix does
not create the NullPointerException:

File = new File("RVT_0306.Xml");

works.

The Exception is:

-----------
java.lang.NullPointerException
at
weblogic.apache.xerces.framework.XMLParser.parse
(XMLParser.java:988)
at weblogic.xml.jaxp.WebLogicXMLReader.parse
(WebLogicXMLReader.java:123)
at weblogic.xml.jaxp.RegistryXMLReader.parse
(RegistryXMLReader.java:125)
at xml.XMLLoader.processDocument
(XMLLoader.java:124)
--------------

the method XMLLoader.processDocument() is here:

--------
public void processDocument() throws Exception {
try {
isLoaderActive = true;

// Create a JAXP SAXParserFactory and
configure it
SAXParserFactory spf =
SAXParserFactory.newInstance(); //Use the
default (non-validating) parser
spf.setValidating(true);

// Create a JAXP SAXParser
SAXParser saxParser = spf.newSAXParser();

// Get the encapsulated SAX XMLReader
XMLReader xmlReader = saxParser.getXMLReader
();
xmlReader.setContentHandler(this);
xmlReader.setDTDHandler(this);
xmlReader.setEntityResolver(this);
xmlReader.setErrorHandler(this);
xmlReader.parse(new InputSource
(inputStream)); //NullPointerException!!!
} catch (Exception e) {
e.printStackTrace(System.err);
throw new Exception
("XMLLoader.processDocument(): " + e);
} finally {
isLoaderActive = false;
}
}//processDocument()
-------------

This error occurs on WIndows NT 4.0 (SP 6) and also on
WIndows 2000 (SP3).

Discussion

  • m.hilpert

    m.hilpert - 2003-08-13

    Logged In: YES
    user_id=667728

    i performed several tests and the problem seesm to be that
    the Reader always throws a NullPointerException, if the base
    file name of the File object that is used for the InputStream
    has not all capitalized letters. so, the capitalization of the file
    on the file system is not important. but the capitalization of
    the Java File object:

    tests: fileName on filesystem + fileName of File object =>
    result :

    rvt_0306.xml + rvt_0305.xml => NullPointerExcption
    RVT_0306.xml + rvt_0305.xml => NullPointerExcption
    rvt_0306.xml + RVT_0305.xml => o.k. (no Exception)
    RVT_0306.xml + RVT_0305.xml => o.k. (no Exception)

     
  • Anonymous - 2003-10-22

    Logged In: YES
    user_id=44117

    There's no way this is a bug in SAX.

    It could be a WebLogic bug, a Windows bug, or a bug in
    the JVM you're using. Or an interaction among all of them.

     
  • Anonymous - 2003-10-22
    • status: open --> closed-invalid
     
  • m.hilpert

    m.hilpert - 2003-10-23

    Logged In: YES
    user_id=667728

    I found the bug and it's not a bug in SAX :-) The problem was
    in my SAX listener processing wrong XML elements. But i
    thought the exception (or at least the stack trace) would
    indicate the problem in my class. instead the exception stack
    trace looks like it's a bug in SAX or WebLogic.
    Sorry for posting, but as you can see by the stack trace,
    there is no custom class of my app involved, so it took a long
    time till i found the bug (by accident).

     

Log in to post a comment.