You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Ka...@salvationarmy.org on 2002/12/04 09:26:08 UTC

NoSuchMethodError/NullPointerException with Lotus Notes 6

Hi,

I am trying to use the Batik transcoder API as part of a Lotus Notes 6 Java agent. The code is pretty much the same as
the SaveAsJpeg example in the documentation and it all works fine until I actually try and transcode the TranscodeInput
into the TranscoderOutput, which gives me the following error:

java.lang.NoSuchMethodError: org.w3c.dom.DOMImplementation: method
createDocument(Ljava/lang/String;Ljava/lang/String;Lorg/w3c/dom/DocumentType;)Lorg/w3c/dom/Document; not found
      at org.apache.batik.dom.util.SAXDocumentFactory.createDocument(Unknown Source)
      at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown Source)
      at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown Source)
      at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown Source)
      at SaveAsJPEG.createJPEG(SaveAsJPEG.java:37)
      at JavaAgent.NotesMain(JavaAgent.java:32)
      at lotus.domino.AgentBase.runNotes(Unknown Source)
      at lotus.domino.NotesThread.run(NotesThread.java:208)

Although Lotus Notes natively uses IBM's XML4j.jar, adding XMLResourceDescriptor.getXMLParserClassName() to the code
returns the following:

org.apache.crimson.parser.XMLReaderImpl

If I remove XML4j.jar from my Notes installation, the agent fails on the same line but  for a different reason:

java.io.IOException: java.lang.NullPointerException
      at org.apache.batik.dom.util.SAXDocumentFactory.createDocument(Unknown Source)
      at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown Source)
      at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown Source)
      at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown Source)
      at SaveAsJPEG.createJPEG(SaveAsJPEG.java:37)
      at JavaAgent.NotesMain(JavaAgent.java:32)
      at lotus.domino.AgentBase.runNotes(Unknown Source)
      at lotus.domino.NotesThread.run(NotesThread.java:208)
org.apache.batik.transcoder.TranscoderException: null
Enclosed Exception:
java.lang.NullPointerException
      at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown Source)
      at SaveAsJPEG.createJPEG(SaveAsJPEG.java:37)
      at JavaAgent.NotesMain(JavaAgent.java:32)
      at lotus.domino.AgentBase.runNotes(Unknown Source)
      at lotus.domino.NotesThread.run(NotesThread.java:208)

Again, XMLResourceDescriptor.getXMLParserClassName() returns the following:

org.apache.crimson.parser.XMLReaderImpl

Has anyone got any ideas? If it helps, Lotus Notes creates a new classpath each time an agent is run, in the following
order:

1) Any classes or archives added to Lotus Notes ini file (I have none)
2) Any default classes or archive files Notes uses (this is where XML4j.jar gets picked up from)
3) And classes or archive files attached to the agent itself (this is where all the Batik files are)

Thanks,

Karl




This email and any files transmitted with it are confidential and intended solely for the use of individuals or entity to whom they are addressed.

If you have received this email in error, please notify The Salvation Army International Headquarters Helpdesk on +44 (0) 20 7398 5466 or the originator of the message.

Any views expressed in this message are those of the individual sender, except where the sender specifies and with the authority, states them to be the views of The Salvation Army International Trustee Company.

[v3.5.1]

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: W3C "valid" SVG documents

Posted by Jane Singer <js...@cc.huji.ac.il>.
OK, I typed that  into the example by mistake, it is not in the document.

I guess my general question is, are the documents created by the
org.apache.batik.dom.svg.SVGDocumentFactory valid W3C documents?
I'm having a lot of trouble combining W3C component with those created by
batik and others. It seems most of my problems have to do with the order I
list things in the classpath.
Jane

----- Original Message -----
From: "Vincent Hardy" <vi...@sun.com>
To: "Batik Users" <ba...@xml.apache.org>
Sent: Wednesday, January 15, 2003 7:52 AM
Subject: Re: W3C "valid" SVG documents


> Hello Jane,
>
> Try your file without the trailing </xml>. It should work better.
> Vincent.
>
> Jane Singer wrote:
> > Hello,
> >
> > I'm creating an SVG file by importing a basic SVG document (along with a
lot
> > of <def> elements), then appending various graphic, text and use
elements,
> > using the various defs.
> >
> > I created the file like this:
> >
> >  File file = new File("F:\\input_output\\basic_document.svg");
> >     try {
> >           String uri = file.toURL().toString();
> >           SVGDocumentFactory df  =
> >           new SAXSVGDocumentFactory
> >           ("org.apache.crimson.parser.XMLReaderImpl");
> >
> >           SVGdoc =  df.createDocument(uri);
> >         } catch (java.io.IOException ioe) {
> >         ioe.printStackTrace();
> >     }
> >
> > The imported file has a structure like this:
> >
> > <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> > <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
> > "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
> > <svg width="600" height="800" viewBox="-10 30 120 80"  >
> >
> > <defs>
> > .
> > .
> > .
> > </defs>
> > </svg>
> > </xml>
> >
> > However, when I try to validate the document at the W3C site
> > (http://validator.w3.org/check), I get an error. The problem is an
element
> > that gets inserted right before the defs element:
> > <svg contentScriptType="text/ecmascript"
> >      xmlns:xlink="http://www.w3.org/1999/xlink" width="600"
> > zoomAndPan="magnify"
> >      contentStyleType="text/css" viewBox="-10 30 120 80" height="800"
> >      preserveAspectRatio="xMidYMid meet"
xmlns="http://www.w3.org/2000/svg"
> >      version="1.0">
> >
> > I'm not sure how this gets inserted. The document validates fine when I
> > remove it. What is going on?
> >
> > (I am also getting errors when I try to view it in JSVGCanvas, which is
why
> > I thought to validate it.)
> >
> > Thanks for any tips.
> >
> > Jane
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> > For additional commands, e-mail: batik-users-help@xml.apache.org
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: W3C "valid" SVG documents

Posted by Vincent Hardy <vi...@sun.com>.
Hello Jane,

Try your file without the trailing </xml>. It should work better.
Vincent.

Jane Singer wrote:
> Hello,
> 
> I'm creating an SVG file by importing a basic SVG document (along with a lot
> of <def> elements), then appending various graphic, text and use elements,
> using the various defs.
> 
> I created the file like this:
> 
>  File file = new File("F:\\input_output\\basic_document.svg");
>     try {
>           String uri = file.toURL().toString();
>           SVGDocumentFactory df  =
>           new SAXSVGDocumentFactory
>           ("org.apache.crimson.parser.XMLReaderImpl");
> 
>           SVGdoc =  df.createDocument(uri);
>         } catch (java.io.IOException ioe) {
>         ioe.printStackTrace();
>     }
> 
> The imported file has a structure like this:
> 
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
> "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
> <svg width="600" height="800" viewBox="-10 30 120 80"  >
> 
> <defs>
> .
> .
> .
> </defs>
> </svg>
> </xml>
> 
> However, when I try to validate the document at the W3C site
> (http://validator.w3.org/check), I get an error. The problem is an element
> that gets inserted right before the defs element:
> <svg contentScriptType="text/ecmascript"
>      xmlns:xlink="http://www.w3.org/1999/xlink" width="600"
> zoomAndPan="magnify"
>      contentStyleType="text/css" viewBox="-10 30 120 80" height="800"
>      preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg"
>      version="1.0">
> 
> I'm not sure how this gets inserted. The document validates fine when I
> remove it. What is going on?
> 
> (I am also getting errors when I try to view it in JSVGCanvas, which is why
> I thought to validate it.)
> 
> Thanks for any tips.
> 
> Jane
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


W3C "valid" SVG documents

Posted by Jane Singer <js...@cc.huji.ac.il>.
Hello,

I'm creating an SVG file by importing a basic SVG document (along with a lot
of <def> elements), then appending various graphic, text and use elements,
using the various defs.

I created the file like this:

 File file = new File("F:\\input_output\\basic_document.svg");
    try {
          String uri = file.toURL().toString();
          SVGDocumentFactory df  =
          new SAXSVGDocumentFactory
          ("org.apache.crimson.parser.XMLReaderImpl");

          SVGdoc =  df.createDocument(uri);
        } catch (java.io.IOException ioe) {
        ioe.printStackTrace();
    }

The imported file has a structure like this:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="600" height="800" viewBox="-10 30 120 80"  >

<defs>
.
.
.
</defs>
</svg>
</xml>

However, when I try to validate the document at the W3C site
(http://validator.w3.org/check), I get an error. The problem is an element
that gets inserted right before the defs element:
<svg contentScriptType="text/ecmascript"
     xmlns:xlink="http://www.w3.org/1999/xlink" width="600"
zoomAndPan="magnify"
     contentStyleType="text/css" viewBox="-10 30 120 80" height="800"
     preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg"
     version="1.0">

I'm not sure how this gets inserted. The document validates fine when I
remove it. What is going on?

(I am also getting errors when I try to view it in JSVGCanvas, which is why
I thought to validate it.)

Thanks for any tips.

Jane




---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


re: NullPointerException at org.apache.crimson.parser.Parser2.parseInternal

Posted by Ka...@salvationarmy.org.
Thomas,

Thanks for sticking with this!

TD>  Ahh, so it's a lower level NPE.  Try changing the println of 'e' to 'e.printStackTrace()' so we can see where the
error is really coming from.

I've added that line and the result is:

SAXDocumentFactory just before parse

SAXDocumentFactory caught exception e:

java.lang.NullPointerException

      at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:524)

      at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)

      at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:433)

      at org.apache.batik.dom.util.SAXDocumentFactory.createDocument(SAXDocumentFactory.java:350)

      at org.apache.batik.dom.util.SAXDocumentFactory.createDocument(SAXDocumentFactory.java:277)

      at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(SAXSVGDocumentFactory.java:158)

      at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(SAXSVGDocumentFactory.java:231)

      at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:118)

      at SaveAsJPEG.createJPEG(SaveAsJPEG.java:46)

      at JavaAgent.NotesMain(JavaAgent.java:32)

      at lotus.domino.AgentBase.runNotes(Unknown Source)

      at lotus.domino.NotesThread.run(NotesThread.java:208)

java.lang.NullPointerException

SAXDocumentFactory line after exception object e is printed:

java.io.IOException: java.lang.NullPointerException

      at org.apache.batik.dom.util.SAXDocumentFactory.createDocument(SAXDocumentFactory.java:361)

      at org.apache.batik.dom.util.SAXDocumentFactory.createDocument(SAXDocumentFactory.java:277)

      at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(SAXSVGDocumentFactory.java:158)

      at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(SAXSVGDocumentFactory.java:231)

      at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:118)

      at SaveAsJPEG.createJPEG(SaveAsJPEG.java:46)

      at JavaAgent.NotesMain(JavaAgent.java:32)

      at lotus.domino.AgentBase.runNotes(Unknown Source)

      at lotus.domino.NotesThread.run(NotesThread.java:208)

org.apache.batik.transcoder.TranscoderException: null
Enclosed Exception:
java.lang.NullPointerException

      at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:126)

      at SaveAsJPEG.createJPEG(SaveAsJPEG.java:46)

      at JavaAgent.NotesMain(JavaAgent.java:32)

      at lotus.domino.AgentBase.runNotes(Unknown Source)

      at lotus.domino.NotesThread.run(NotesThread.java:208)

Thanks,

Karl


This email and any files transmitted with it are confidential and intended solely for the use of individuals or entity to whom they are addressed.

If you have received this email in error, please notify The Salvation Army International Headquarters Helpdesk on +44 (0) 20 7398 5466 or the originator of the message.

Any views expressed in this message are those of the individual sender, except where the sender specifies and with the authority, states them to be the views of The Salvation Army International Trustee Company.

[v3.5.1]

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


RE: Slight progress.....NullPointerException

Posted by Ka...@salvationarmy.org.
Thomas,

Thanks for sticking with this!

TD>  Ahh, so it's a lower level NPE.  Try changing the println of 'e' to 'e.printStackTrace()' so we can see where the
error is really coming from.

I've added that line and the result is:

SAXDocumentFactory just before parse

SAXDocumentFactory caught exception e:

java.lang.NullPointerException

      at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:524)

      at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)

      at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:433)

      at org.apache.batik.dom.util.SAXDocumentFactory.createDocument(SAXDocumentFactory.java:350)

      at org.apache.batik.dom.util.SAXDocumentFactory.createDocument(SAXDocumentFactory.java:277)

      at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(SAXSVGDocumentFactory.java:158)

      at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(SAXSVGDocumentFactory.java:231)

      at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:118)

      at SaveAsJPEG.createJPEG(SaveAsJPEG.java:46)

      at JavaAgent.NotesMain(JavaAgent.java:32)

      at lotus.domino.AgentBase.runNotes(Unknown Source)

      at lotus.domino.NotesThread.run(NotesThread.java:208)

java.lang.NullPointerException

SAXDocumentFactory line after exception object e is printed:

java.io.IOException: java.lang.NullPointerException

      at org.apache.batik.dom.util.SAXDocumentFactory.createDocument(SAXDocumentFactory.java:361)

      at org.apache.batik.dom.util.SAXDocumentFactory.createDocument(SAXDocumentFactory.java:277)

      at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(SAXSVGDocumentFactory.java:158)

      at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(SAXSVGDocumentFactory.java:231)

      at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:118)

      at SaveAsJPEG.createJPEG(SaveAsJPEG.java:46)

      at JavaAgent.NotesMain(JavaAgent.java:32)

      at lotus.domino.AgentBase.runNotes(Unknown Source)

      at lotus.domino.NotesThread.run(NotesThread.java:208)

org.apache.batik.transcoder.TranscoderException: null
Enclosed Exception:
java.lang.NullPointerException

      at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:126)

      at SaveAsJPEG.createJPEG(SaveAsJPEG.java:46)

      at JavaAgent.NotesMain(JavaAgent.java:32)

      at lotus.domino.AgentBase.runNotes(Unknown Source)

      at lotus.domino.NotesThread.run(NotesThread.java:208)

Thanks,

Karl



This email and any files transmitted with it are confidential and intended solely for the use of individuals or entity to whom they are addressed.

If you have received this email in error, please notify The Salvation Army International Headquarters Helpdesk on +44 (0) 20 7398 5466 or the originator of the message.

Any views expressed in this message are those of the individual sender, except where the sender specifies and with the authority, states them to be the views of The Salvation Army International Trustee Company.

[v3.5.1]

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


RE: Slight progress.....NullPointerException

Posted by Thomas E Deweese <th...@kodak.com>.
>>>>> "KL" == Karl Larsson <Ka...@salvationarmy.org> writes:

KL> I discovered that I had to 'refresh' the modified jars in Notes -
KL> not just re-import them. I am now getting the System.out messages:

KL> } catch (SAXException e) {
KL> System.out.println("SAXDocumentFactory caught exception e:");
KL> System.out.println(e); 

KL> SAXDocumentFactory caught exception e: 
KL> java.lang.NullPointerException 

    Ahh, so it's a lower level NPE.  Try changing the println of 'e'
to 'e.printStackTrace()' so we can see where the error is really
coming from.


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Slight progress.....NullPointerException

Posted by Ka...@salvationarmy.org.
Thomas,

I discovered that I had to 'refresh' the modified jars in Notes - not just re-import them. I am now getting the
System.out messages:

Code Excerpt:

            System.out.println("SAXDocumentFactory just before parse");
            parser.parse(is);
            System.out.println("SAXDocumentFactory just after parse");
      } catch (SAXException e) {
            System.out.println("SAXDocumentFactory caught exception e:");
            System.out.println(e);
            System.out.println("SAXDocumentFactory line after exception object e is printed:");
            Exception ex = e.getException();
            if (ex != null && ex instanceof InterruptedIOException) {
                throw (InterruptedIOException)ex;
            }
            throw new IOException(e.getMessage());
      }

Result:

SAXDocumentFactory just before parse
SAXDocumentFactory caught exception e:
java.lang.NullPointerException
SAXDocumentFactory line after exception object e is printed:

java.io.IOException: java.lang.NullPointerException
      at org.apache.batik.dom.util.SAXDocumentFactory.createDocument(SAXDocumentFactory.java:360)
      at org.apache.batik.dom.util.SAXDocumentFactory.createDocument(SAXDocumentFactory.java:277)
      at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(SAXSVGDocumentFactory.java:158)
      at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(SAXSVGDocumentFactory.java:231)
      at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:118)
      at SaveAsJPEG.createJPEG(SaveAsJPEG.java:46)
      at JavaAgent.NotesMain(JavaAgent.java:32)
      at lotus.domino.AgentBase.runNotes(Unknown Source)
      at lotus.domino.NotesThread.run(NotesThread.java:208)

org.apache.batik.transcoder.TranscoderException: null
Enclosed Exception:
java.lang.NullPointerException
      at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:126)
      at SaveAsJPEG.createJPEG(SaveAsJPEG.java:46)
      at JavaAgent.NotesMain(JavaAgent.java:32)
      at lotus.domino.AgentBase.runNotes(Unknown Source)
      at lotus.domino.NotesThread.run(NotesThread.java:208)

The "SAXDocumentFactory just after parse" line isn't getting printed, so I guess the problem line is:

parser.parse(is);

As per my previous message, I have upgraded to batik-src-1.5beta4b.zip and the test SVG can be opened with no problems
in squiggle.

Karl



This email and any files transmitted with it are confidential and intended solely for the use of individuals or entity to whom they are addressed.

If you have received this email in error, please notify The Salvation Army International Headquarters Helpdesk on +44 (0) 20 7398 5466 or the originator of the message.

Any views expressed in this message are those of the individual sender, except where the sender specifies and with the authority, states them to be the views of The Salvation Army International Trustee Company.

[v3.5.1]

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


RE: NullPointerException

Posted by Ka...@salvationarmy.org.
Thomas,

TD> 1) Make sure this is the problem code by inserting System.out statements (since you can build the jars now this
should be fairly easy). In particular I would print 'e' first thing in the catch.  I would also put in prints before and
after the call to'parser.parse(is)'.

After upgrading to batik-src-1.5beta4b.zip, I added the various System.out statements to the SaxDocumentFactory code as
follows:

parser.parse(is);
System.out.println("hello after parse");
} catch (SAXException e) {
System.out.println("hello before e");
System.out.println(e);
Exception ex = e.getException();
if (ex != null && ex instanceof InterruptedIOException) {
throw (InterruptedIOException)ex;
}
throw new IOException(e.getMessage());
}

I then rebuilt the JAR files and reimported them into my Lotus Notes agent, but couldn't see the statements anywhere
when it failed:

java.io.IOException: java.lang.NullPointerException
      at org.apache.batik.dom.util.SAXDocumentFactory.createDocument(SAXDocumentFactory.java:353)
      at org.apache.batik.dom.util.SAXDocumentFactory.createDocument(SAXDocumentFactory.java:276)
      at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(SAXSVGDocumentFactory.java:158)
      at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(SAXSVGDocumentFactory.java:231)
      at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:118)
      at SaveAsJPEG.createJPEG(SaveAsJPEG.java:46)
      at JavaAgent.NotesMain(JavaAgent.java:32)
      at lotus.domino.AgentBase.runNotes(Unknown Source)
      at lotus.domino.NotesThread.run(NotesThread.java:208)

org.apache.batik.transcoder.TranscoderException: null
Enclosed Exception:
java.lang.NullPointerException
      at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:126)
      at SaveAsJPEG.createJPEG(SaveAsJPEG.java:46)
      at JavaAgent.NotesMain(JavaAgent.java:32)
      at lotus.domino.AgentBase.runNotes(Unknown Source)
      at lotus.domino.NotesThread.run(NotesThread.java:208)

It does have different line numbers now that may make more sense to you though! I checked to see if any of the default
Notes JARs contained SAXDocumentFactory, but couldn't see it anywhere:

Notes.jar;
liveconn.jar;
XML4j.jar;
LotusXSL.jar;
rt.jar;
i18n.jar;
tools.jar;
servlet.jar

TD> Can an you open the SVG file you are trying to parse here in Squiggle? If the Namespace or top level element is
wrong you might see a problem here also.

Yeah - it was fine.

Karl




This email and any files transmitted with it are confidential and intended solely for the use of individuals or entity to whom they are addressed.

If you have received this email in error, please notify The Salvation Army International Headquarters Helpdesk on +44 (0) 20 7398 5466 or the originator of the message.

Any views expressed in this message are those of the individual sender, except where the sender specifies and with the authority, states them to be the views of The Salvation Army International Trustee Company.

[v3.5.1]

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


RE: NullPointerException

Posted by Thomas E Deweese <th...@kodak.com>.
>>>>> "KL" == Karl Larsson <Ka...@salvationarmy.org> writes:

TD> Doh! You didn't print out 'parser'. I wanted to know if it was
TD> NULL. :)

KL> Gives:

KL> "org.apache.crimson.parser.XMLReaderImpl@6b3f271c"

    Ok so you can build the parser fine (so it's _proably_ not a
classpath issue).

KL> I downloaded 'batik-src-1.1.1.zip 18-Dec-2001 01:49' and built the
KL> jar files using the debug option.

    Ohh, hmm lots has changed in the parser arena since 1.1.1.  You
might consider upgrading to 1.5b4...

    Ok, so it looks like the parse is failing but the exception thrown
seems to be a bit wacko, since it dies on what looks to be a fine line
of code:

   [....]
            parser.parse(is);
      } catch (SAXException e) {
            Exception ex = e.getException();
            if (ex != null && ex instanceof InterruptedIOException) {
                throw (InterruptedIOException)ex;
            }
-->         throw new IOException(e.getMessage());
      }
   [...]

   I consider this an odd place to get an NPE.  We know 'e' isn't null
(you can't throw null can you?).  So 'e.getMessage()' must return null
(or something even weirder is happening).

   So I have two suggestions:

   1) Make sure this is the problem code by inserting System.out
statements (since you can build the jars now this should be fairly
easy). In particular I would print 'e' first thing in the catch.  I
would also put in prints before and after the call to
'parser.parse(is)'.

   2) Try Batik 1.5b4.

   Can you open the SVG file you are trying to parse here in Squiggle?
If the Namespace or top level element is wrong you might see a problem
here also.

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


RE: NullPointerException

Posted by Ka...@salvationarmy.org.
Hi Thomas,

TD> Doh! You didn't print out 'parser'. I wanted to know if it was NULL. :)

Nope :-)

XMLReader parser = XMLReaderFactory.createXMLReader("org.apache.crimson.parser.XMLReaderImpl");
XMLResourceDescriptor.setXMLParserClassName("org.apache.crimson.parser.XMLReaderImpl");
System.out.println(parser);

Gives:

"org.apache.crimson.parser.XMLReaderImpl@6b3f271c"

TD> Hmm, your line numbers aren't matching my source (not even close enoguht to help really)...  What version of Batik
are you using? (or easier for me can you send me the SAXDocumentFactory.java and SAXSVGDocumentFactory.java you are
using).

I downloaded 'batik-src-1.1.1.zip  18-Dec-2001 01:49' and built the jar files using the debug option.

Here's SAXDocumentFactory.java (C:\Batik\xml-batik\sources\org\apache\batik\dom\util):

/*****************************************************************************
 * Copyright (C) The Apache Software Foundation. All rights reserved.        *
 * ------------------------------------------------------------------------- *
 * This software is published under the terms of the Apache Software License *
 * version 1.1, a copy of which has been included with this distribution in  *
 * the LICENSE file.                                                         *
 *****************************************************************************/

package org.apache.batik.dom.util;

import java.io.InputStream;
import java.io.InterruptedIOException;
import java.io.IOException;
import java.io.Reader;

import org.apache.batik.css.ElementWithID;

import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.DOMException;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.helpers.XMLReaderFactory;

/**
 * This class contains methods for creating Document instances
 * from an URI using SAX2.
 *
 * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
 * @version $Id: SAXDocumentFactory.java,v 1.5 2001/11/06 09:40:34 hillion Exp $
 */
public class SAXDocumentFactory
    extends    DefaultHandler
    implements LexicalHandler,
               DocumentFactory {

    /**
     * The DOM implementation used to create the document.
     */
    protected DOMImplementation implementation;

    /**
     * The SAX2 parser classname.
     */
    protected String parserClassName;

    /**
     * The created document.
     */
    protected Document document;

    /**
     * The created document descriptor.
     */
    protected DocumentDescriptor documentDescriptor;

    /**
     * Whether a document descriptor must be generated.
     */
    protected boolean createDocumentDescriptor;

    /**
     * The current node.
     */
    protected Node currentNode;

    /**
     * The locator.
     */
    protected Locator locator;

    /**
     * Whether the parser currently parses a CDATA section.
     */
    protected boolean inCDATA;

    /**
     * Whether the parser currently parses a DTD.
     */
    protected boolean inDTD;

    /**
     * Whether the parser is in validating mode.
     */
    protected boolean isValidating;

    /**
     * Whether the document element has been parsed.
     */
    protected boolean documentElementParsed;

    /**
     * The stack used to store the namespace URIs.
     */
    protected HashTableStack namespaces;

    /**
     * Creates a new SAXDocumentFactory object.
     * No document descriptor will be created while generating a document.
     * @param impl The DOM implementation to use for building the DOM tree.
     * @param parser The SAX2 parser classname.
     */
    public SAXDocumentFactory(DOMImplementation impl,
                              String parser) {
      implementation           = impl;
      parserClassName          = parser;
    }

    /**
     * Creates a new SAXDocumentFactory object.
     * @param impl The DOM implementation to use for building the DOM tree.
     * @param parser The SAX2 parser classname.
     * @param dd Whether a document descriptor must be generated.
     */
    public SAXDocumentFactory(DOMImplementation impl,
                              String parser,
                              boolean dd) {
      implementation           = impl;
      parserClassName          = parser;
        createDocumentDescriptor = dd;
    }

    /**
     * Creates a Document instance.
     * @param ns The namespace URI of the root element of the document.
     * @param root The name of the root element of the document.
     * @param uri The document URI.
     * @exception IOException if an error occured while reading the document.
     */
    public Document createDocument(String ns, String root, String uri)
        throws IOException {
        return createDocument(ns, root, uri, new InputSource(uri));
    }

    /**
     * Creates a Document instance.
     * @param ns The namespace URI of the root element of the document.
     * @param root The name of the root element of the document.
     * @param uri The document URI.
     * @param is The document input stream.
     * @exception IOException if an error occured while reading the document.
     */
    public Document createDocument(String ns, String root, String uri,
                           InputStream is) throws IOException {
        InputSource inp = new InputSource(is);
        inp.setSystemId(uri);
        return createDocument(ns, root, uri, inp);
    }

    /**
     * Creates a Document instance.
     * @param ns The namespace URI of the root element of the document.
     * @param root The name of the root element of the document.
     * @param uri The document URI.
     * @param r The document reader.
     * @exception IOException if an error occured while reading the document.
     */
    public Document createDocument(String ns, String root, String uri, Reader r)
        throws IOException {
        InputSource inp = new InputSource(r);
        inp.setSystemId(uri);
        return createDocument(ns, root, uri, inp);
    }

    /**
     * Creates a GenericDocument.
     * @param ns The namespace URI of the root element.
     * @param root The name of the root element.
     * @param uri The document URI.
     * @param is  The document input source.
     * @exception IOException if an error occured while reading the document.
     */
    protected Document createDocument(String ns, String root, String uri,
                                      InputSource is)
      throws IOException {
      document = implementation.createDocument(ns, root, null);

      try {
            XMLReader parser = XMLReaderFactory.createXMLReader(parserClassName);

            parser.setContentHandler(this);
            parser.setDTDHandler(this);
            parser.setEntityResolver(this);
            parser.setErrorHandler(this);

            parser.setFeature("http://xml.org/sax/features/namespaces",
                        true);
            parser.setFeature("http://xml.org/sax/features/namespace-prefixes",
                              true);
          parser.setFeature("http://xml.org/sax/features/validation",
                        isValidating);
          parser.setProperty("http://xml.org/sax/properties/lexical-handler",
                         this);
            parser.parse(is);
      } catch (SAXException e) {
            Exception ex = e.getException();
            if (ex != null && ex instanceof InterruptedIOException) {
                throw (InterruptedIOException)ex;
            }
            throw new IOException(e.getMessage());
      }

      return document;
    }

    /**
     * Returns the document descriptor associated with the latest created
     * document.
     * @return null if no document or descriptor was previously generated.
     */
    public DocumentDescriptor getDocumentDescriptor() {
        return documentDescriptor;
    }

    /**
     * <b>SAX</b>: Implements {@link
     * org.xml.sax.ContentHandler#setDocumentLocator(Locator)}.
     */
    public void setDocumentLocator(Locator l) {
        locator = l;
    }

    /**
     * Sets whether or not the XML parser will validate the XML document
     * depending on the specified parameter.
     *
     * @param isValidating indicates that the XML parser will validate the XML
     * document
     */
    public void setValidating(boolean isValidating) {
      this.isValidating = isValidating;
    }

    /**
     * Returns true if the XML parser validates the XML stream, false otherwise.
     */
    public boolean isValidating() {
      return isValidating;
    }

    /**
     * <b>SAX</b>: Implements {@link
     * org.xml.sax.ContentHandler#startDocument()}.
     */
    public void startDocument() throws SAXException {
        namespaces = new HashTableStack();
      namespaces.put("xml", XMLSupport.XML_NAMESPACE_URI);
      namespaces.put("xmlns", XMLSupport.XMLNS_NAMESPACE_URI);
      namespaces.put("", null);

      documentElementParsed = false;
        inCDATA = false;
        inDTD = false;
      currentNode = document;

        if (createDocumentDescriptor) {
            documentDescriptor = new DocumentDescriptor();
        } else {
            documentDescriptor = null;
        }
    }

    /**
     * <b>SAX</b>: Implements {@link
     * ContentHandler#startElement(String,String,String,Attributes)}.
     */
    public void startElement(String     uri,
                       String     localName,
                       String     rawName,
                       Attributes attributes) throws SAXException {
        // Check for interruption.
        if (Thread.currentThread().isInterrupted()) {
            throw new SAXException(new InterruptedIOException());
        }

      // Namespaces resolution
      int len = attributes.getLength();
      namespaces.push();
      for (int i = 0; i < len; i++) {
          String aname = attributes.getQName(i);
          if (aname.equals("xmlns")) {
            namespaces.put("", attributes.getValue(i));
          } else {
            if (aname.startsWith("xmlns:")) {
                int idx = aname.indexOf(':');
                namespaces.put(aname.substring(idx + 1),
                           attributes.getValue(i));
            }
          }
      }

      // Element creation
      Element e;
      int idx = rawName.indexOf(':');
      String nsp = (idx == -1 || idx == rawName.length()-1)
          ? ""
          : rawName.substring(0, idx);
      String nsURI = namespaces.get(nsp);

      if (currentNode == document) {
          e = document.getDocumentElement();
          String lname = rawName;
          if (idx != -1 && idx != rawName.length()-1) {
            lname = rawName.substring(idx+1);
          }
          if (e.getNamespaceURI() != null && nsp.length() != 0) {
            if (!e.getLocalName().equals(lname)) {
                throw new SAXException("Bad root element");
            }
            e.setPrefix(nsp);
          }
          String xmlns;
          Attr attr = (nsp.equals(""))
            ? e.getAttributeNodeNS(XMLSupport.XMLNS_NAMESPACE_URI,
                               xmlns = "xmlns")
            : e.getAttributeNodeNS(XMLSupport.XMLNS_NAMESPACE_URI,
                               xmlns = "xmlns:" + nsp);
          if (attr != null) {
            namespaces.put(nsp, attr.getValue());
          }
          documentElementParsed = true;
      } else {
          e = document.createElementNS(nsURI, rawName);
          currentNode.appendChild(e);
      }
      currentNode = e;

        // Storage of the line number.
        if (createDocumentDescriptor && locator != null) {
            documentDescriptor.setLocationLine(e, locator.getLineNumber());
        }

      // Attributes creation
      for (int i = 0; i < len; i++) {
          String aname = attributes.getQName(i);
          if (aname.equals("xmlns")) {
            e.setAttributeNS(XMLSupport.XMLNS_NAMESPACE_URI,
                         aname,
                         attributes.getValue(i));
          } else {
            idx = aname.indexOf(':');
            nsURI = (idx == -1)
                    ? null
                    : namespaces.get(aname.substring(0, idx));
            e.setAttributeNS(nsURI, aname, attributes.getValue(i));
            if (attributes.getType(i).equals("ID") &&
                e instanceof ElementWithID) {
                String s = (idx == -1 || idx == aname.length()-1)
                  ? aname
                  : aname.substring(idx + 1);
                ((ElementWithID)e).setIDName(nsURI, s);
            }
          }
      }
    }

    /**
     * <b>SAX</b>: Implements {@link
     * org.xml.sax.ErrorHandler#error(SAXParseException)}.
     */
    public void error(SAXParseException ex) throws SAXException {
      throw ex;
    }

    /**
     * <b>SAX</b>: Implements {@link
     * org.xml.sax.ErrorHandler#warning(SAXParseException)}.
     */
    public void warning(SAXParseException ex) throws SAXException {
      throw ex;
    }

    /**
     * <b>SAX</b>: Implements {@link
     * org.xml.sax.ContentHandler#endElement(String,String,String)}.
     */
    public void endElement(String uri, String localName, String rawName)
      throws SAXException {
      currentNode = currentNode.getParentNode();
      namespaces.pop();
    }

    /**
     * <b>SAX</b>: Implements {@link
     * org.xml.sax.ContentHandler#characters(char[],int,int)}.
     */
    public void characters(char ch[], int start, int length)
        throws SAXException {
      String data = new String(ch, start, length);
      Node n = (inCDATA)
          ? document.createCDATASection(data)
          : document.createTextNode(data);
      currentNode.appendChild(n);
    }

    /**
     * <b>SAX</b>: Implements {@link
     * org.xml.sax.ContentHandler#processingInstruction(String,String)}.
     */
    public void processingInstruction(String target, String data)
        throws SAXException {
      if (!inDTD) {
          Node n = document.createProcessingInstruction(target, data);
          if (currentNode == document && !documentElementParsed) {
            currentNode.insertBefore(n, document.getDocumentElement());
          } else {
            currentNode.appendChild(n);
          }
      }
    }

    // LexicalHandler /////////////////////////////////////////////////////////

    /**
     * <b>SAX</b>: Implements {@link
     * org.xml.sax.ext.LexicalHandler#startDTD(String,String,String)}.
     */
    public void startDTD(String name, String publicId, String systemId)
      throws SAXException {
      inDTD = true;
    }

    /**
     * <b>SAX</b>: Implements {@link org.xml.sax.ext.LexicalHandler#endDTD()}.
     */
    public void endDTD() throws SAXException {
      inDTD = false;
    }

    /**
     * <b>SAX</b>: Implements
     * {@link org.xml.sax.ext.LexicalHandler#startEntity(String)}.
     */
    public void startEntity(String name) throws SAXException {
    }

    /**
     * <b>SAX</b>: Implements
     * {@link org.xml.sax.ext.LexicalHandler#endEntity(String)}.
     */
    public void endEntity(String name) throws SAXException {
    }

    /**
     * <b>SAX</b>: Implements {@link
     * org.xml.sax.ext.LexicalHandler#startCDATA()}.
     */
    public void startCDATA() throws SAXException {
      inCDATA = true;
    }

    /**
     * <b>SAX</b>: Implements {@link
     * org.xml.sax.ext.LexicalHandler#endCDATA()}.
     */
    public void endCDATA() throws SAXException {
      inCDATA = false;
    }

    /**
     * <b>SAX</b>: Implements
     * {@link org.xml.sax.ext.LexicalHandler#comment(char[],int,int)}.
     */
    public void comment(char ch[], int start, int length) throws SAXException {
      if (!inDTD) {
          Node n = document.createComment(new String(ch, start, length));
          if (currentNode == document && !documentElementParsed) {
            currentNode.insertBefore(n, document.getDocumentElement());
          } else {
            currentNode.appendChild(n);
          }
      }
    }
}

and here's SAXSVGDocumentFactory.java (C:\Batik\xml-batik\sources\org\apache\batik\dom\svg):

/*****************************************************************************
 * Copyright (C) The Apache Software Foundation. All rights reserved.        *
 * ------------------------------------------------------------------------- *
 * This software is published under the terms of the Apache Software License *
 * version 1.1, a copy of which has been included with this distribution in  *
 * the LICENSE file.                                                         *
 *****************************************************************************/

package org.apache.batik.dom.svg;

import java.io.InputStream;
import java.io.IOException;
import java.io.Reader;

import java.net.MalformedURLException;
import java.net.URL;

import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

import java.util.zip.GZIPInputStream;

import org.apache.batik.dom.util.SAXDocumentFactory;
import org.apache.batik.util.ParsedURL;
import org.apache.batik.util.MimeTypeConstants;

import org.w3c.dom.Document;
import org.w3c.dom.DOMException;

import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

/**
 * This class contains methods for creating SVGDocument instances
 * from an URI using SAX2.
 *
 * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
 * @version $Id: SAXSVGDocumentFactory.java,v 1.12 2001/11/06 09:40:34 hillion Exp $
 */
public class SAXSVGDocumentFactory
    extends    SAXDocumentFactory
    implements SVGDocumentFactory {

    /**
     * The dtd public IDs resource bundle class name.
     */
    protected final static String DTDIDS =
        "org.apache.batik.dom.svg.resources.dtdids";

    /**
     * Constant for HTTP content type header charset field.
     */
    protected final static String HTTP_CHARSET = "charset";

    /**
     * The accepted DTD public IDs.
     */
    protected static String dtdids;

    /**
     * Creates a new SVGDocumentFactory object.
     * @param parser The SAX2 parser classname.
     */
    public SAXSVGDocumentFactory(String parser) {
        super(ExtensibleSVGDOMImplementation.getDOMImplementation(), parser);
    }

    /**
     * Creates a new SVGDocumentFactory object.
     * @param parser The SAX2 parser classname.
     * @param dd Whether a document descriptor must be generated.
     */
    public SAXSVGDocumentFactory(String parser, boolean dd) {
        super(ExtensibleSVGDOMImplementation.getDOMImplementation(), parser, dd);
    }

    /**
     * Creates a SVGOMDocument instance.<br>
     * This method supports gzipped sources.
     * @param uri The document URI.
     * @exception IOException if an error occured while reading the document.
     */
    public SVGOMDocument createDocument(String uri) throws IOException {
        ParsedURL purl = new ParsedURL(uri);

        InputStream is = purl.openStream(MimeTypeConstants.MIME_TYPES_SVG);

        InputSource isrc = new InputSource(is);

        // now looking for a charset encoding in the content type such
        // as "image/svg+xml; charset=iso8859-1" this is not official
        // for image/svg+xml yet! only for text/xml and maybe
        // for application/xml
        String contentType = purl.getContentType();
        int cindex = -1;
        if (contentType != null) {
            contentType = contentType.toLowerCase();
            cindex = contentType.indexOf(HTTP_CHARSET);
        }

        if (cindex != -1) {
            int i                 = cindex + HTTP_CHARSET.length();
            int eqIdx = contentType.indexOf('=', i);
            if (eqIdx != -1) {
                eqIdx++; // no one is interested in the equals sign...

                String charset;
                // The patch had ',' as the terminator but I suspect
                // that is the delimiter between possible charsets,
                // but if another 'attribute' were in the accept header
                // charset would be terminated by a ';'.  So I look
                // for both and take to closer of the two.
                int idx     = contentType.indexOf(',', eqIdx);
                int semiIdx = contentType.indexOf(';', eqIdx);
                if ((semiIdx != -1) && ((semiIdx < idx) || (idx == -1)))
                    idx = semiIdx;
                if (idx != -1)
                    charset = contentType.substring(eqIdx, idx);
                else
                    charset = contentType.substring(eqIdx);
                isrc.setEncoding(charset.trim());
            }
        }

        isrc.setSystemId(uri);

        SVGOMDocument doc = (SVGOMDocument)super.createDocument
            (SVGDOMImplementation.SVG_NAMESPACE_URI, "svg", uri, isrc);
        try {
            doc.setURLObject(new URL(purl.toString()));
        } catch (MalformedURLException mue) {
            // Not very likely to happen given we already opened the stream.
            throw new IOException("Malformed URL: " + uri);
        }

        return doc;
    }

    /**
     * Creates a SVGOMDocument instance.
     * @param uri The document URI.
     * @param is The document input stream.
     * @exception IOException if an error occured while reading the document.
     */
    public SVGOMDocument createDocument(String uri, InputStream inp) throws IOException {
        SVGOMDocument doc;
        InputSource is = new InputSource(inp);
        is.setSystemId(uri);

        try {
            doc = (SVGOMDocument)super.createDocument
                (SVGDOMImplementation.SVG_NAMESPACE_URI, "svg", uri, is);
            if (uri != null) {
                doc.setURLObject(new URL(uri));
            }
        } catch (MalformedURLException e) {
            throw new IOException(e.getMessage());
        }
        return doc;
    }

    /**
     * Creates a SVGOMDocument instance.
     * @param uri The document URI.
     * @param r The document reader.
     * @exception IOException if an error occured while reading the document.
     */
    public SVGOMDocument createDocument(String uri, Reader r) throws IOException {
        SVGOMDocument doc;
        InputSource is = new InputSource(r);
        is.setSystemId(uri);

        try {
            doc = (SVGOMDocument)super.createDocument
                (SVGDOMImplementation.SVG_NAMESPACE_URI, "svg", uri, is);
            if (uri != null) {
                doc.setURLObject(new URL(uri));
            }
        } catch (MalformedURLException e) {
            throw new IOException(e.getMessage());
        }
        return doc;
    }

    /**
     * Creates a Document instance.
     * @param ns The namespace URI of the root element of the document.
     * @param root The name of the root element of the document.
     * @param uri The document URI.
     * @exception IOException if an error occured while reading the document.
     */
    public Document createDocument(String ns, String root, String uri)
        throws IOException {
        if (!SVGDOMImplementation.SVG_NAMESPACE_URI.equals(ns) ||
            !"svg".equals(root)) {
            throw new RuntimeException("Bad root element");
        }
        return createDocument(uri);
    }

    /**
     * Creates a Document instance.
     * @param ns The namespace URI of the root element of the document.
     * @param root The name of the root element of the document.
     * @param uri The document URI.
     * @param is The document input stream.
     * @exception IOException if an error occured while reading the document.
     */
    public Document createDocument(String ns, String root, String uri, InputStream is)
        throws IOException {
        if (!SVGDOMImplementation.SVG_NAMESPACE_URI.equals(ns) ||
            !"svg".equals(root)) {
            throw new RuntimeException("Bad root element");
        }
        return createDocument(uri, is);
    }

    /**
     * Creates a Document instance.
     * @param ns The namespace URI of the root element of the document.
     * @param root The name of the root element of the document.
     * @param uri The document URI.
     * @param r The document reader.
     * @exception IOException if an error occured while reading the document.
     */
    public Document createDocument(String ns, String root, String uri, Reader r)
        throws IOException {
        if (!SVGDOMImplementation.SVG_NAMESPACE_URI.equals(ns) ||
            !"svg".equals(root)) {
            throw new RuntimeException("Bad root element");
        }
        return createDocument(uri, r);
    }

    /**
     * <b>SAX2</b>: Implements {@link
     * org.xml.sax.EntityResolver#resolveEntity(String,String)}.
     */
    public InputSource resolveEntity(String publicId, String systemId)
        throws SAXException {
        try {
            if (dtdids == null) {
                ResourceBundle rb;
                rb = ResourceBundle.getBundle(DTDIDS,
                                              Locale.getDefault());
                dtdids = rb.getString("publicIds");
            }
            if (dtdids.indexOf(publicId) != -1) {
                return new InputSource
                    (getClass().getResource
                     ("resources/svg10.dtd").toString());
            }
        } catch (MissingResourceException e) {
            throw new SAXException(e);
        }
        // Let the SAX parser find the entity.
        return null;
    }
}

Sorry about the long message!

Karl


This email and any files transmitted with it are confidential and intended solely for the use of individuals or entity to whom they are addressed.

If you have received this email in error, please notify The Salvation Army International Headquarters Helpdesk on +44 (0) 20 7398 5466 or the originator of the message.

Any views expressed in this message are those of the individual sender, except where the sender specifies and with the authority, states them to be the views of The Salvation Army International Trustee Company.

[v3.5.1]

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


RE: NullPointerException

Posted by Thomas E Deweese <th...@kodak.com>.
Hi Karl,


>>>>> "KL" == Karl Larsson <Ka...@salvationarmy.org> writes:

KL> Thanks for your help again:

TD> I asked if you could create the reader yourself.  Did you try:

TD> XMLReader parser =
TD> XMLReaderFactory.createXMLReader(parserClassName);

TD> Where parserClassName is the crimson parser impl?

KL> Yes - The following code...

KL> XMLReader parser =
KL> XMLReaderFactory.createXMLReader("org.apache.crimson.parser.XMLReaderImpl");

KL> XMLResourceDescriptor.setXMLParserClassName("org.apache.crimson.parser.XMLReaderImpl");
KL> String parserStr = XMLResourceDescriptor.getXMLParserClassName();
KL> System.out.println(parserStr);

KL> ...still gives the response:

KL> "org.apache.crimson.parser.XMLReaderImpl"

    Doh! You didn't print out 'parser'. I wanted to know if it was
NULL. :)

TD> You will probably need to build your own copy of the Batik Jars
TD> with the debug="on" property set for Ant (per my previous
TD> message).

KL> OK - I managed that, and it came out with the following stack
KL> trace:

    Hmm, your line numbers aren't matching my source (not even close
enoguht to help really)...  What version of Batik are you using? (or
easier for me can you send me the SAXDocumentFactory.java and
SAXSVGDocumentFactory.java you are using).

KL> java.io.IOException: java.lang.NullPointerException

KL>       at
KL> org.apache.batik.dom.util.SAXDocumentFactory.createDocument(SAXDocumentFactory.java:211)

KL>       at
KL> org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(SAXSVGDocumentFactory.java:128)


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


RE: NullPointerException

Posted by Ka...@salvationarmy.org.
Thomas,

Thanks for your help again:

TD> I asked if you could create the reader yourself.  Did you try:

TD> XMLReader parser = XMLReaderFactory.createXMLReader(parserClassName);

TD> Where parserClassName is the crimson parser impl?

Yes - The following code...

XMLReader parser = XMLReaderFactory.createXMLReader("org.apache.crimson.parser.XMLReaderImpl");
XMLResourceDescriptor.setXMLParserClassName("org.apache.crimson.parser.XMLReaderImpl");
String parserStr = XMLResourceDescriptor.getXMLParserClassName();
System.out.println(parserStr);

...still gives the response:

"org.apache.crimson.parser.XMLReaderImpl"

TD> You will probably need to build your own copy of the Batik Jars with the debug="on" property set for Ant (per my
previous message).

OK - I managed that, and it came out with the following stack trace:

java.io.IOException: java.lang.NullPointerException

      at org.apache.batik.dom.util.SAXDocumentFactory.createDocument(SAXDocumentFactory.java:211)

      at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(SAXSVGDocumentFactory.java:128)

      at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(SAXSVGDocumentFactory.java:199)

      at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:118)

      at SaveAsJPEG.createJPEG(SaveAsJPEG.java:47)

      at JavaAgent.NotesMain(JavaAgent.java:32)

      at lotus.domino.AgentBase.runNotes(Unknown Source)

      at lotus.domino.NotesThread.run(NotesThread.java:208)

org.apache.batik.transcoder.TranscoderException: null
Enclosed Exception:
java.lang.NullPointerException

      at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:126)

      at SaveAsJPEG.createJPEG(SaveAsJPEG.java:47)

      at JavaAgent.NotesMain(JavaAgent.java:32)

      at lotus.domino.AgentBase.runNotes(Unknown Source)

      at lotus.domino.NotesThread.run(NotesThread.java:208)

Thanks again for any suggestions.

Karl





This email and any files transmitted with it are confidential and intended solely for the use of individuals or entity to whom they are addressed.

If you have received this email in error, please notify The Salvation Army International Headquarters Helpdesk on +44 (0) 20 7398 5466 or the originator of the message.

Any views expressed in this message are those of the individual sender, except where the sender specifies and with the authority, states them to be the views of The Salvation Army International Trustee Company.

[v3.5.1]

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


RE: NullPointerException

Posted by Thomas E Deweese <th...@kodak.com>.
>>>>> "KL" == Karl Larsson <Ka...@salvationarmy.org> writes:

TD> It would be really helpful if you could send a stack trace with
TD> line numbers.

KL> I don't think I can get a stack trace with line numbers using
KL> Domino.

    I think you can since your code has line numbers:

KL>       at [...].XMLAbstractTranscoder.transcode(Unknown Source)
KL>       at SaveAsJPEG.createJPEG(SaveAsJPEG.java:48)
KL>       at JavaAgent.NotesMain(JavaAgent.java:32)
                                 ^^^^^^^^^^^^^^^^^
    You will probably need to build your own copy of the Batik Jars
with the debug="on" property set for Ant (per my previous message).

TD> Which probably means a problem with parserClassName (which comes
TD> from XMLResourceDescriptor.getXMLParserClassName() which you print
TD> out in your code below - does it look right?).  Can you create the
TD> XMLReader yourself?

KL> The following lines in my code:

KL> String parserStr = XMLResourceDescriptor.getXMLParserClassName();
KL> System.out.println(parserStr);

KL> give this result:

KL> "org.apache.crimson.parser.XMLReaderImpl"

    So that looks ok, assuming the crimson parser is on your path...

KL> so it appears that the Crimson parser is being used. I have also
KL> tried adding the following line to force the issue:

KL> t.addTranscodingHint(JPEGTranscoder.KEY_XML_PARSER_CLASSNAME,
KL>   "org.apache.crimson.parser.XMLReaderImpl");

KL> Then, the following lines:

KL> Finally, when we get to the line:

KL> t.transcode(input, output);

KL> we get the following exception:

KL> java.io.IOException: java.lang.NullPointerException

    I asked if you could create the reader yourself.  Did you try:

            XMLReader parser =
                XMLReaderFactory.createXMLReader(parserClassName);

    Where parserClassName is the crimson parser impl?

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


RE: NullPointerException

Posted by Ka...@salvationarmy.org.
Thomas,

TD> It would be really helpful if you could send a stack trace with line numbers.

I don't think I can get a stack trace with line numbers using Domino.

TD> Without that I'm mostly guessing, but I think that SAXDocumentFactory.java:330 is the problem:

TD> XMLReader parser = XMLReaderFactory.createXMLReader(parserClassName);

TD> Which probably means a problem with parserClassName (which comes from XMLResourceDescriptor.getXMLParserClassName()
TD> which you print out in your code below - does it look right?).  Can you create the XMLReader yourself?

The following lines in my code:

String parserStr = XMLResourceDescriptor.getXMLParserClassName();
System.out.println(parserStr);

give this result:

"org.apache.crimson.parser.XMLReaderImpl"

so it appears that the Crimson parser is being used. I have also tried adding the following line to force the issue:

t.addTranscodingHint(JPEGTranscoder.KEY_XML_PARSER_CLASSNAME,"org.apache.crimson.parser.XMLReaderImpl");

Then, the following lines:

String svgURI = new File(inputFilePath, inputFileName).toURL().toString();
TranscoderInput input = new TranscoderInput(svgURI);
System.out.println("input: " + svgURI);

OutputStream ostream = new FileOutputStream("c:\\batik\\batik-1.1.1\\samples\\out.jpg");
TranscoderOutput output = new TranscoderOutput(ostream);
System.out.println("transcoder output: " + output.getOutputStream());

print out the following:

"input: file:/c:/batik/batik-1.1.1/samples/gvt.svg"
"transcoder output: java.io.FileOutputStream@51cc5a21"

Finally, when we get to the line:

t.transcode(input, output);

we get the following exception:

java.io.IOException: java.lang.NullPointerException

      at org.apache.batik.dom.util.SAXDocumentFactory.createDocument(Unknown Source)

      at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown Source)

      at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown Source)

      at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown Source)

      at SaveAsJPEG.createJPEG(SaveAsJPEG.java:48)

      at JavaAgent.NotesMain(JavaAgent.java:32)

      at lotus.domino.AgentBase.runNotes(Unknown Source)

      at lotus.domino.NotesThread.run(NotesThread.java:208)

org.apache.batik.transcoder.TranscoderException: null
Enclosed Exception:
java.lang.NullPointerException

      at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown Source)

      at SaveAsJPEG.createJPEG(SaveAsJPEG.java:48)

      at JavaAgent.NotesMain(JavaAgent.java:32)

      at lotus.domino.AgentBase.runNotes(Unknown Source)

      at lotus.domino.NotesThread.run(NotesThread.java:208)

Thanks,

Karl


This email and any files transmitted with it are confidential and intended solely for the use of individuals or entity to whom they are addressed.

If you have received this email in error, please notify The Salvation Army International Headquarters Helpdesk on +44 (0) 20 7398 5466 or the originator of the message.

Any views expressed in this message are those of the individual sender, except where the sender specifies and with the authority, states them to be the views of The Salvation Army International Trustee Company.

[v3.5.1]

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


RE: NullPointerException

Posted by Thomas E Deweese <th...@kodak.com>.
>>>>> "KL" == Karl Larsson <Ka...@salvationarmy.org> writes:

KL> Thanks for your help. I have now got the batik / crimson JAR files
KL> first on my classpath, but when I get to the transcode line, in
KL> throws this error:

    It would be really helpful if you could send a stack trace with
line numbers.  There are like a dozen createDocument methods in
SAXDocumentFactory.  If you have a source distribution the easiest way
to make a debug build is to put a build.properties file with the line
'debug=on' in it in the xml-batik directory (right next to the
build.xml file).

    Without that I'm mostly guessing, but I think that
    SAXDocumentFactory.java:330 is the problem:

            XMLReader parser =
                XMLReaderFactory.createXMLReader(parserClassName);

    Which probably means a problem with parserClassName (which comes
from XMLResourceDescriptor.getXMLParserClassName() which you print out
in your code below - does it look right?).  Can you create the
XMLReader yourself?

    Of course it could be any of number of other places, the above is
just an educated guess, line numbers would _really_ help.

KL> java.io.IOException: java.lang.NullPointerException at
KL> org.apache.batik.dom.util.SAXDocumentFactory.createDocument(Unknown
KL> Source) at
KL> org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown
KL> Source) at
KL> org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown
KL> Source) at
KL> org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown
KL> Source) at SaveAsJPEG.createJPEG(SaveAsJPEG.java:43) at
KL> JavaAgent.NotesMain(JavaAgent.java:32) at
KL> lotus.domino.AgentBase.runNotes(Unknown Source) at
KL> lotus.domino.NotesThread.run(NotesThread.java:208)

KL> org.apache.batik.transcoder.TranscoderException: null Enclosed
KL> Exception: java.lang.NullPointerException at
KL> org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown
KL> Source) at SaveAsJPEG.createJPEG(SaveAsJPEG.java:43) at
KL> JavaAgent.NotesMain(JavaAgent.java:32) at
KL> lotus.domino.AgentBase.runNotes(Unknown Source) at
KL> lotus.domino.NotesThread.run(NotesThread.java:208)

KL> Here is the code I am using. I pass in the following strings from
KL> another class in the Domino agent:

KL> inputFilePath = "c:\\batik\\batik-1.1.1\\samples\\" inputFileName
KL> = "gvt.svg"

KL> //Start.....................................................

KL> import java.io.*; import
KL> org.apache.batik.transcoder.image.JPEGTranscoder; import
KL> org.apache.batik.transcoder.TranscoderInput; import
KL> org.apache.batik.transcoder.TranscoderOutput; import
KL> org.apache.batik.util.XMLResourceDescriptor; import
KL> org.w3c.dom.DOMImplementation;

KL> public class SaveAsJPEG {

KL>         public void createJPEG( String inputFilePath, String
KL> inputFileName) throws Exception {

KL>             String parserStr =
KL> XMLResourceDescriptor.getXMLParserClassName();
KL> System.out.println(parserStr);

KL>             System.out.println("Getting transcoder....");
KL> JPEGTranscoder t = new JPEGTranscoder();

KL>             System.out.println("set the transcoding hints:
KL> quality"); t.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new
KL> Float(.8));

KL>             System.out.println("create the transcoder input");
KL> String svgURI = new File(inputFilePath,
KL> inputFileName).toURL().toString(); System.out.println(svgURI);
KL> TranscoderInput input = new TranscoderInput(svgURI);

KL>             System.out.println("create the transcoder output");
KL> OutputStream ostream = new FileOutputStream("out.jpg");
KL> TranscoderOutput output = new TranscoderOutput(ostream);
KL> System.out.println(output.getOutputStream());

KL>             System.out.println("save the image");
KL> t.transcode(input, output);

KL>             System.out.println("flush and close the stream then
KL> exit"); ostream.flush(); ostream.close();

KL>         System.exit(0);

KL>     } }

KL> //End.....................................................

KL> Have you got any ideas?

KL> Thanks,

KL> Karl



                                                                                                                        
KL>              Thomas E Deweese <th...@kodak.com> To
KL> 04/12/2002 12:49 Batik Users <ba...@xml.apache.org> cc
                                                                                                                        
KL>                       Please respond to Subject "Batik Users" RE:
KL> NoSuchMethodError/NullPointerException with Lotus Notes 6
KL> <ba...@xml.apache.org>
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        




>>>>> "KL" == Karl Larsson <Ka...@salvationarmy.org> writes:

KL> I am trying to use the Batik transcoder API as part of a Lotus
KL> Notes 6 Java agent. The code is pretty much the same as the
KL> SaveAsJpeg example in the documentation and it all works fine
KL> until I actually try and transcode the TranscodeInput into the
KL> TranscoderOutput, which gives me the following error:

KL> java.lang.NoSuchMethodError: org.w3c.dom.DOMImplementation: method
KL> createDocument(Ljava/lang/String;Ljava/lang/String;Lorg/w3c/dom/DocumentType;)Lorg/w3c/dom/Document;

KL>     No such method exceptions are almost always caused by picking
KL> up a DOM implementation that does not support styling.  You need
KL> to make sure that the DOM interface included with Batik is earlier
KL> on the class path for the agent than what ever DOM Lotus Notes is
KL> including (I don't know how you would do that or even if it is
KL> possible in Notes).

KL> not found at
KL> org.apache.batik.dom.util.SAXDocumentFactory.createDocument(Unknown
KL> Source) at
KL> org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown
KL> Source) at
KL> org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown
KL> Source) at
KL> org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown
KL> Source) at SaveAsJPEG.createJPEG(SaveAsJPEG.java:37) at
KL> JavaAgent.NotesMain(JavaAgent.java:32) at
KL> lotus.domino.AgentBase.runNotes(Unknown Source) at
KL> lotus.domino.NotesThread.run(NotesThread.java:208)

KL> Although Lotus Notes natively uses IBM's XML4j.jar, adding
KL> XMLResourceDescriptor.getXMLParserClassName() to the code returns
KL> the following:

KL> org.apache.crimson.parser.XMLReaderImpl

KL> If I remove XML4j.jar from my Notes installation, the agent fails
KL> on the same line but for a different reason:

KL> java.io.IOException: java.lang.NullPointerException at
KL> org.apache.batik.dom.util.SAXDocumentFactory.createDocument(Unknown
KL> Source) at

KL>     It's a little hard to tell without line numbers but I think
KL> this is most likely caused by the call to
KL> XMLReaderFactor.createXMLReader(parserClassName) returning Null
KL> (i.e.  org.apache.crimson.parser.XMLReaderImpl isn't available).

KL>     You can build a debug version by putting adding a
KL> build.properties file in the root of the batik source distribution
KL> with the line 'debug=on' in it.

KL> org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown
KL> Source) at
KL> org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown
KL> Source) at
KL> org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown
KL> Source) at SaveAsJPEG.createJPEG(SaveAsJPEG.java:37) at
KL> JavaAgent.NotesMain(JavaAgent.java:32) at
KL> lotus.domino.AgentBase.runNotes(Unknown Source) at
KL> lotus.domino.NotesThread.run(NotesThread.java:208)
KL> org.apache.batik.transcoder.TranscoderException: null Enclosed
KL> Exception: java.lang.NullPointerException at
KL> org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown
KL> Source) at SaveAsJPEG.createJPEG(SaveAsJPEG.java:37) at
KL> JavaAgent.NotesMain(JavaAgent.java:32) at
KL> lotus.domino.AgentBase.runNotes(Unknown Source) at
KL> lotus.domino.NotesThread.run(NotesThread.java:208)

KL> Again, XMLResourceDescriptor.getXMLParserClassName() returns the
KL> following:

KL> org.apache.crimson.parser.XMLReaderImpl

KL> Has anyone got any ideas? If it helps, Lotus Notes creates a new
KL> classpath each time an agent is run, in the following order:

KL> 1) Any classes or archives added to Lotus Notes ini file (I have
KL> none) 2) Any default classes or archive files Notes uses (this is
KL> where XML4j.jar gets picked up from) 3) And classes or archive
KL> files attached to the agent itself (this is where all the Batik
KL> files are)

KL>     Yah, so you need to get the Batik DOM interfaces up into 1 (it
KL> is in batik-ext.jar). Also in #3 do you have all the stuff in lib
KL> (like crimson-parser.jar)?

KL> ---------------------------------------------------------------------
KL> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org For
KL> additional commands, e-mail: batik-users-help@xml.apache.org





KL> This email and any files transmitted with it are confidential and
KL> intended solely for the use of individuals or entity to whom they
KL> are addressed.

KL> If you have received this email in error, please notify The
KL> Salvation Army International Headquarters Helpdesk on +44 (0) 20
KL> 7398 5466 or the originator of the message.

KL> Any views expressed in this message are those of the individual
KL> sender, except where the sender specifies and with the authority,
KL> states them to be the views of The Salvation Army International
KL> Trustee Company.

KL> [v3.5.1]

KL> ---------------------------------------------------------------------
KL> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org For
KL> additional commands, e-mail: batik-users-help@xml.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


NullPointerException

Posted by Ka...@salvationarmy.org.
Thomas,

Thanks for your help. I have now got the batik / crimson JAR files first on my classpath, but when I get to the
transcode line, in throws this error:

java.io.IOException: java.lang.NullPointerException
at org.apache.batik.dom.util.SAXDocumentFactory.createDocument(Unknown Source)
at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown Source)
at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown Source)
at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown Source)
at SaveAsJPEG.createJPEG(SaveAsJPEG.java:43)
at JavaAgent.NotesMain(JavaAgent.java:32)
at lotus.domino.AgentBase.runNotes(Unknown Source)
at lotus.domino.NotesThread.run(NotesThread.java:208)

org.apache.batik.transcoder.TranscoderException: null
Enclosed Exception:
java.lang.NullPointerException
at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown Source)
at SaveAsJPEG.createJPEG(SaveAsJPEG.java:43)
at JavaAgent.NotesMain(JavaAgent.java:32)
at lotus.domino.AgentBase.runNotes(Unknown Source)
at lotus.domino.NotesThread.run(NotesThread.java:208)

Here is the code I am using. I pass in the following strings from another class in the Domino agent:

inputFilePath = "c:\\batik\\batik-1.1.1\\samples\\"
inputFileName = "gvt.svg"

//Start.....................................................

import java.io.*;
import org.apache.batik.transcoder.image.JPEGTranscoder;
import org.apache.batik.transcoder.TranscoderInput;
import org.apache.batik.transcoder.TranscoderOutput;
import org.apache.batik.util.XMLResourceDescriptor;
import org.w3c.dom.DOMImplementation;

public class SaveAsJPEG {

        public void createJPEG( String inputFilePath, String inputFileName)
           throws Exception {

            String parserStr = XMLResourceDescriptor.getXMLParserClassName();
            System.out.println(parserStr);

            System.out.println("Getting transcoder....");
            JPEGTranscoder t = new JPEGTranscoder();

            System.out.println("set the transcoding hints: quality");
                   t.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(.8));

            System.out.println("create the transcoder input");
            String svgURI = new File(inputFilePath, inputFileName).toURL().toString();
                  System.out.println(svgURI);
            TranscoderInput input = new TranscoderInput(svgURI);

            System.out.println("create the transcoder output");
            OutputStream ostream = new FileOutputStream("out.jpg");
            TranscoderOutput output = new TranscoderOutput(ostream);
            System.out.println(output.getOutputStream());

            System.out.println("save the image");
            t.transcode(input, output);

            System.out.println("flush and close the stream then exit");
            ostream.flush();
            ostream.close();

        System.exit(0);

    }
}

//End.....................................................

Have you got any ideas?

Thanks,

Karl



                                                                                                                        
             Thomas E Deweese                                                                                           
             <th...@kodak.com>                                                                                 
                                                                                                                     To 
             04/12/2002 12:49                            Batik Users <ba...@xml.apache.org>                       
                                                                                                                     cc 
                                                                                                                        
                      Please respond to                                                                         Subject 
                        "Batik Users"                    RE: NoSuchMethodError/NullPointerException with Lotus Notes 6  
                <ba...@xml.apache.org>                                                                            
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        




>>>>> "KL" == Karl Larsson <Ka...@salvationarmy.org> writes:

KL> I am trying to use the Batik transcoder API as part of a Lotus
KL> Notes 6 Java agent. The code is pretty much the same as the
KL> SaveAsJpeg example in the documentation and it all works fine
KL> until I actually try and transcode the TranscodeInput into the
KL> TranscoderOutput, which gives me the following error:

KL> java.lang.NoSuchMethodError:
KL>   org.w3c.dom.DOMImplementation: method
KL> createDocument(Ljava/lang/String;Ljava/lang/String;Lorg/w3c/dom/DocumentType;)Lorg/w3c/dom/Document;

    No such method exceptions are almost always caused by picking up a
DOM implementation that does not support styling.  You need to make
sure that the DOM interface included with Batik is earlier on the
class path for the agent than what ever DOM Lotus Notes is including
(I don't know how you would do that or even if it is possible in
Notes).

KL> not found at
KL> org.apache.batik.dom.util.SAXDocumentFactory.createDocument(Unknown
KL> Source) at
KL> org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown
KL> Source) at
KL> org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown
KL> Source) at
KL> org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown
KL> Source) at SaveAsJPEG.createJPEG(SaveAsJPEG.java:37) at
KL> JavaAgent.NotesMain(JavaAgent.java:32) at
KL> lotus.domino.AgentBase.runNotes(Unknown Source) at
KL> lotus.domino.NotesThread.run(NotesThread.java:208)

KL> Although Lotus Notes natively uses IBM's XML4j.jar, adding
KL> XMLResourceDescriptor.getXMLParserClassName() to the code returns
KL> the following:

KL> org.apache.crimson.parser.XMLReaderImpl

KL> If I remove XML4j.jar from my Notes installation, the agent fails
KL> on the same line but for a different reason:

KL> java.io.IOException: java.lang.NullPointerException at
KL> org.apache.batik.dom.util.SAXDocumentFactory.createDocument(Unknown
KL> Source) at

    It's a little hard to tell without line numbers but I think this
is most likely caused by the call to
XMLReaderFactor.createXMLReader(parserClassName) returning Null (i.e.
org.apache.crimson.parser.XMLReaderImpl isn't available).

    You can build a debug version by putting adding a build.properties
file in the root of the batik source distribution with the line
'debug=on' in it.

KL> org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown
KL> Source) at
KL> org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown
KL> Source) at
KL> org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown
KL> Source) at SaveAsJPEG.createJPEG(SaveAsJPEG.java:37) at
KL> JavaAgent.NotesMain(JavaAgent.java:32) at
KL> lotus.domino.AgentBase.runNotes(Unknown Source) at
KL> lotus.domino.NotesThread.run(NotesThread.java:208)
KL> org.apache.batik.transcoder.TranscoderException: null Enclosed
KL> Exception: java.lang.NullPointerException at
KL> org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown
KL> Source) at SaveAsJPEG.createJPEG(SaveAsJPEG.java:37) at
KL> JavaAgent.NotesMain(JavaAgent.java:32) at
KL> lotus.domino.AgentBase.runNotes(Unknown Source) at
KL> lotus.domino.NotesThread.run(NotesThread.java:208)

KL> Again, XMLResourceDescriptor.getXMLParserClassName() returns the
KL> following:

KL> org.apache.crimson.parser.XMLReaderImpl

KL> Has anyone got any ideas? If it helps, Lotus Notes creates a new
KL> classpath each time an agent is run, in the following order:

KL> 1) Any classes or archives added to Lotus Notes ini file (I have
KL> none) 2) Any default classes or archive files Notes uses (this is
KL> where XML4j.jar gets picked up from) 3) And classes or archive
KL> files attached to the agent itself (this is where all the Batik
KL> files are)

    Yah, so you need to get the Batik DOM interfaces up into 1 (it is
in batik-ext.jar). Also in #3 do you have all the stuff in lib (like
crimson-parser.jar)?

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org





This email and any files transmitted with it are confidential and intended solely for the use of individuals or entity to whom they are addressed.

If you have received this email in error, please notify The Salvation Army International Headquarters Helpdesk on +44 (0) 20 7398 5466 or the originator of the message.

Any views expressed in this message are those of the individual sender, except where the sender specifies and with the authority, states them to be the views of The Salvation Army International Trustee Company.

[v3.5.1]

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


RE: NoSuchMethodError/NullPointerException with Lotus Notes 6

Posted by Thomas E Deweese <th...@kodak.com>.
>>>>> "KL" == Karl Larsson <Ka...@salvationarmy.org> writes:

KL> I am trying to use the Batik transcoder API as part of a Lotus
KL> Notes 6 Java agent. The code is pretty much the same as the
KL> SaveAsJpeg example in the documentation and it all works fine
KL> until I actually try and transcode the TranscodeInput into the
KL> TranscoderOutput, which gives me the following error:

KL> java.lang.NoSuchMethodError: 
KL>   org.w3c.dom.DOMImplementation: method 
KL> createDocument(Ljava/lang/String;Ljava/lang/String;Lorg/w3c/dom/DocumentType;)Lorg/w3c/dom/Document;

    No such method exceptions are almost always caused by picking up a
DOM implementation that does not support styling.  You need to make
sure that the DOM interface included with Batik is earlier on the
class path for the agent than what ever DOM Lotus Notes is including
(I don't know how you would do that or even if it is possible in
Notes).

KL> not found at
KL> org.apache.batik.dom.util.SAXDocumentFactory.createDocument(Unknown
KL> Source) at
KL> org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown
KL> Source) at
KL> org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown
KL> Source) at
KL> org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown
KL> Source) at SaveAsJPEG.createJPEG(SaveAsJPEG.java:37) at
KL> JavaAgent.NotesMain(JavaAgent.java:32) at
KL> lotus.domino.AgentBase.runNotes(Unknown Source) at
KL> lotus.domino.NotesThread.run(NotesThread.java:208)

KL> Although Lotus Notes natively uses IBM's XML4j.jar, adding
KL> XMLResourceDescriptor.getXMLParserClassName() to the code returns
KL> the following:

KL> org.apache.crimson.parser.XMLReaderImpl

KL> If I remove XML4j.jar from my Notes installation, the agent fails
KL> on the same line but for a different reason:

KL> java.io.IOException: java.lang.NullPointerException at
KL> org.apache.batik.dom.util.SAXDocumentFactory.createDocument(Unknown
KL> Source) at

    It's a little hard to tell without line numbers but I think this
is most likely caused by the call to
XMLReaderFactor.createXMLReader(parserClassName) returning Null (i.e.
org.apache.crimson.parser.XMLReaderImpl isn't available).

    You can build a debug version by putting adding a build.properties
file in the root of the batik source distribution with the line
'debug=on' in it.

KL> org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown
KL> Source) at
KL> org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown
KL> Source) at
KL> org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown
KL> Source) at SaveAsJPEG.createJPEG(SaveAsJPEG.java:37) at
KL> JavaAgent.NotesMain(JavaAgent.java:32) at
KL> lotus.domino.AgentBase.runNotes(Unknown Source) at
KL> lotus.domino.NotesThread.run(NotesThread.java:208)
KL> org.apache.batik.transcoder.TranscoderException: null Enclosed
KL> Exception: java.lang.NullPointerException at
KL> org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown
KL> Source) at SaveAsJPEG.createJPEG(SaveAsJPEG.java:37) at
KL> JavaAgent.NotesMain(JavaAgent.java:32) at
KL> lotus.domino.AgentBase.runNotes(Unknown Source) at
KL> lotus.domino.NotesThread.run(NotesThread.java:208)

KL> Again, XMLResourceDescriptor.getXMLParserClassName() returns the
KL> following:

KL> org.apache.crimson.parser.XMLReaderImpl

KL> Has anyone got any ideas? If it helps, Lotus Notes creates a new
KL> classpath each time an agent is run, in the following order:

KL> 1) Any classes or archives added to Lotus Notes ini file (I have
KL> none) 2) Any default classes or archive files Notes uses (this is
KL> where XML4j.jar gets picked up from) 3) And classes or archive
KL> files attached to the agent itself (this is where all the Batik
KL> files are)

    Yah, so you need to get the Batik DOM interfaces up into 1 (it is
in batik-ext.jar). Also in #3 do you have all the stuff in lib (like
crimson-parser.jar)?

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org