I've been trying to use the Digester module on its own (i.e. no other Struts
code, no servlets, no JSP), and have been having problems. At first, I
thought it must be my application code, but then I tried copying the code
from the Struts example DatabaseServlet into my own Java application and
came across the same problem.

The problem happens when addSetProperties() is used. The call itself
succeeds, but later on, when Digester.parse() is called, I get the following
error and call stack:

java.lang.NullPointerException
        at
org.apache.struts.digester.SetPropertiesRule.begin(SetPropertiesRule.java,
Compiled Code)
        at org.apache.struts.digester.Digester.startElement(Digester.java,
Compiled Code)
        at com.sun.xml.parser.Parser.maybeElement(Parser.java:1391)
        at com.sun.xml.parser.Parser.content(Parser.java:1499)
        at com.sun.xml.parser.Parser.maybeElement(Parser.java:1400)
        at com.sun.xml.parser.Parser.parseInternal(Parser.java:492)
        at com.sun.xml.parser.Parser.parse(Parser.java:284)
        at javax.xml.parsers.SAXParser.parse(SAXParser.java:155)
        at javax.xml.parsers.SAXParser.parse(SAXParser.java:77)
        at org.apache.struts.digester.Digester.parse(Digester.java:708)
        at mfnc.TryDigester.TryDatabase(TryDigester.java:92)
        at mfnc.TryDigester.main(TryDigester.java:18)
org.xml.sax.SAXException

If I comment out the calls to addSetProperties(), everything works just fine
(except that I don't have the property values I wanted :-) ).

Anyone have any ideas about what I might be doing wrong? I know this isn't
how the Digester is expected to be used, but, well, it just seemed like a
handy class for parsing simple XML files...

Thanks!

--
Martin Cooper
Tumbleweed Communications



Reply via email to