xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kenneth B. Harwood" <run10ks...@comcast.net>
Subject Fw: loadSVGDocument generates NullPointerException
Date Sun, 14 Aug 2005 06:34:22 GMT
Wishful thinking.  I took out all of the Thread stuff; 
almost running barebones. I'm still having the same 
NPE problem.

Take a look that this abbreviated StackTrace (full
trace available below):

java.lang.NullPointerException
 at java.util.Properties$LineReader.readLine(Unknown Source)
 at java.util.Properties.load(Unknown Source)
 at org.apache.batik.util.XMLResourceDescriptor.getParserProps(Unknown Source)
 at org.apache.batik.util.XMLResourceDescriptor.getXMLParserClassName(Unknown Source)
 at org.apache.batik.swing.svg.JSVGComponent$BridgeUserAgent.getXMLParserClassName(Unknown
Source)
 at org.apache.batik.swing.svg.JSVGComponent$BridgeUserAgentWrapper.getXMLParserClassName(Unknown
Source)
 at org.apache.batik.bridge.DocumentLoader.<init>(Unknown Source)
 at org.apache.batik.swing.svg.JSVGComponent$1.run(Unknown Source)
 at org.apache.batik.swing.svg.JSVGComponent.stopThenRun(Unknown Source)
 at org.apache.batik.swing.svg.JSVGComponent.loadSVGDocument(Unknown Source)  <<<<<<<<<
LOOK HERE!


I am running this JSVGCanvas inside an Applet.  Oddly, my SVG 
file loads just fine when I run the same code as an application.  

The trace points me to batik class XMLResourceDescriptor.
I've looked at the source code.  The class is trying to recover 
some Properties.  I'm writing an applet; I haven't defined any
(ie no RuntimePermission classes used).


What exactly is going on here? 

Thanks.

 - Ken H.





From: Kenneth B. Harwood 
Sent: Thursday, August 11, 2005 10:04 PM


Woops.  I think I figured out what the problem was:

My <run> method did *not* have a loop in it so the
Thread ran straight to the end of the method and
"gracefully" terminated. By the time I tried to load 
the SVG file my Thread was probably already "dead".

Does this sound reasonable?

I'm still seeing that initial ModifyThreadGroup error
but the NPE has vanished.

 - Ken H.

  ----- Original Message ----- 
  From: Kenneth B. Harwood 
  Sent: Thursday, August 11, 2005 1:46 PM


  My system configuration:

  Batik 1.6
  J2SE 5.0/JApplet
  Apache/Tomcat/MySQL
  Windows 2K Pro

  Problem description:

  I create a JSVGCanvas, initially "blank" (no SVG file
  displayed) then I put the instance in a new thread.
  I then start() the Thread.  Each time my program 
  reaches the following block:

  public void run() {
         pack();
        try {
              jSVGCanvas.loadSVGDocument("http://www.mydomain.com/default.svg"); //NPE THROWN
HERE!
          } catch (Exception expn) {
              System.out.println("Error loading SVG file.");
              expn.printStackTrace();
          }

          setVisible(true);
  }


  I get a NullPointerException.  Here's the entire stackTrace:

  java.lang.NullPointerException
   at com.mydomain.run(myclass.java:38)
   at java.lang.Thread.run(Unknown Source)

   
  I catch the Exception so I continue on.  What happens next 
  depends on my mouse clicks.  For example, after experiencing
  a ModifyThreadGroup error (a problem for another day) I *can* 
  get my SVG file to appear.  After that, I can even load a different 
  SVG file in response to a Menu click (see below).

  Sometimes, depending on my mouse click sequence, when I try 
  to load an SVG in response to a Menu Action, I get this sort of 
  lengthy NPE error:

  java.lang.NullPointerException
   at java.util.Properties$LineReader.readLine(Unknown Source)
   at java.util.Properties.load(Unknown Source)
   at org.apache.batik.util.XMLResourceDescriptor.getParserProps(Unknown Source)
   at org.apache.batik.util.XMLResourceDescriptor.getXMLParserClassName(Unknown Source)
   at org.apache.batik.swing.svg.JSVGComponent$BridgeUserAgent.getXMLParserClassName(Unknown
Source)
   at org.apache.batik.swing.svg.JSVGComponent$BridgeUserAgentWrapper.getXMLParserClassName(Unknown
Source)
   at org.apache.batik.bridge.DocumentLoader.<init>(Unknown Source)
   at org.apache.batik.swing.svg.JSVGComponent$1.run(Unknown Source)
   at org.apache.batik.swing.svg.JSVGComponent.stopThenRun(Unknown Source)
   at org.apache.batik.swing.svg.JSVGComponent.loadSVGDocument(Unknown Source)  <<<<<<<<<
LOOK HERE!
   at myclass.jMenuItem2Chosen(myclass.java:104)
   at myclass.access$100(myclass.java:17)
   at myclass.$3.actionPerformed(myclass.java:88)
   at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
   at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
   at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
   at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
   at javax.swing.AbstractButton.doClick(Unknown Source)
   at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
   at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
   at java.awt.Component.processMouseEvent(Unknown Source)
   at javax.swing.JComponent.processMouseEvent(Unknown Source)
   at java.awt.Component.processEvent(Unknown Source)
   at java.awt.Container.processEvent(Unknown Source)
   at java.awt.Component.dispatchEventImpl(Unknown Source)
   at java.awt.Container.dispatchEventImpl(Unknown Source)
   at java.awt.Component.dispatchEvent(Unknown Source)
   at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
   at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
   at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
   at java.awt.Container.dispatchEventImpl(Unknown Source)
   at java.awt.Window.dispatchEventImpl(Unknown Source)
   at java.awt.Component.dispatchEvent(Unknown Source)
   at java.awt.EventQueue.dispatchEvent(Unknown Source)
   at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
   at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
   at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
   at java.awt.EventDispatchThread.run(Unknown Source)

   
  BTW, my design calls for potentially multiple JSVGCanvas's; each
  one runs in its own thread.  I think my thread-related stuff if O.K.
  although I am certainly *NOT* a Java guru.  Still, when I run the 
  loadSVGDocument code in a very simple test (not using a separate 
  thread) the SVG file comes up *No Problem*. [scratching my head]

  I've reviewed the Batik-users archive.  I've see plenty of individual
  messages regarding NPE, plenty related to loadSVGDocument, but 
  *nothing* related to both.

  Ideas?  Suggestions?

  Thanks.

   - Ken H.
Mime
View raw message