Whenever I try to convert any SVG using the Transcoder API, it gives me following error: java.io.IOException: java.lang.NullPointerException at org.apache.batik.dom.util.SAXDocumentFactory.createDocument(SAXDocume ntFactory.java:353) at org.apache.batik.dom.util.SAXDocumentFactory.createDocument(SAXDocume ntFactory.java:276) at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(SAXSVGD ocumentFactory.java:158) at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(SAXSVGD ocumentFactory.java:231) at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstra ctTranscoder.java:118) at SaveAsJPEG.main(SaveAsJPEG.java:26) Exception in thread "main" org.apache.batik.transcoder.TranscoderException: null Enclosed Exception: java.lang.NullPointerException What should I do ???? :( at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstra ctTranscoder.java:126) at SVG2JPEG.main(SaveAsJPEG.java:26)
I'd like to help but the line numbers don't seem to match anything. Can you either use current CVS or batik 1.5.1 for line numbers.
Reassigning all open bugs to the development list. Sorry for the mass mailing.
Hi, org.apache.batik.dom.util.SAXDocumentFactory cause a java.lang.NullPointerException when it is created with a SAX source that doesn't refer to an InputSource the method startElement() contains the following lines: isStandalone = parser.getFeature ("http://xml.org/sax/features/is-standalone"); but the variable parser is null if the method createDocument(InputSource is) has not been called before (and if the SAX source is made of a Reader for example, it won't be callde) suggestion: correct the code in the method startElement() like this: isStandalone = parser == null ? true : parser.getFeature ("http://xml.org/sax/features/is-standalone"); Regards, P. Poulard
Created attachment 23523 [details] Patched copy of SAXDocumentFactory Here's a patch for this bug. Basically, the NPE is caused because the parser member variable is not set by createDocument if the transcoder is created using an XMLReader. I added 1 line at line 308, first line in public Document createDocument(String ns, String root, String uri, XMLReader r) parser = r;