Bug 33447 - Null Pointer Exception in TranscoderAPI
Summary: Null Pointer Exception in TranscoderAPI
Status: NEW
Alias: None
Product: Batik - Now in Jira
Classification: Unclassified
Component: SVG Rasterizer (show other bugs)
Version: 1.8
Hardware: PC Windows 98
: P1 critical
Target Milestone: ---
Assignee: Batik Developer's Mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-08 16:48 UTC by Jean Claude Van Dame
Modified: 2009-04-21 12:12 UTC (History)
1 user (show)



Attachments
Patched copy of SAXDocumentFactory (24.58 KB, patch)
2009-04-21 12:12 UTC, Dan Bennett
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jean Claude Van Dame 2005-02-08 16:48:59 UTC
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)
Comment 1 Thomas Deweese 2005-02-17 03:25:53 UTC
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.
Comment 2 Thomas Deweese 2005-03-22 12:16:41 UTC
Reassigning all open bugs to the development list.
Sorry for the mass mailing.
Comment 3 ppoulard 2008-11-28 08:03:32 UTC
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
Comment 4 Dan Bennett 2009-04-21 12:12:08 UTC
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;