Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
Hi All, I am currently working on parsing an XML document such that Java objects could be created and stored in the database. I chose to use SAX since I will only be reading the data, creating the objects and populating the DB. A NullPointerException, java.lang.NullPointerException at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:658) at org.apache.crimson.parser.Parser2.parse(Parser2.java:333) at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448) is generated with the following lines of code: SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser parser = spf.newSAXParser(); XMLReader reader = parser.getXMLReader(); reader.setContentHandler(this); reader.parse(new InputSource("file:///C|/temp/temp.xml")); Is the error occuring a result of not being able to locate the file? Is there something missing on the classpath (currently using JDK 1.4)? Thanks in advance for your help!
Typically, if a file isn't found a more descriptive exception will be thrown. You're going to have to debug this, or at least find out which object is null when it shouldn't be. It's possible you haven't configured an XML parser like Xerces on your computer, or having included it in your classpath, so your factory in turn returns null when you ask for a SAX parser. You can step through it in your debugger to find out. Or more likely the stack trace will print out the line where the null pointer exception was thrown.