You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Elod Horvath <el...@itfais.com> on 2001/01/04 01:03:03 UTC

RE: Problem with Digester used "standalone" (REF: BugRat report #692)

NullPointerException using CallMethodRule in Digester.  This occurs if the
parameters to the method call are specified as being primitive types.  For
example, the following excerpt from the Digester init:
 
digester.addCallMethod(
          "quickmenu-config/entry/visibility",
//        "setAppIDSense", 1, new String[] {"java.lang.Boolean"});
          "setAppIDSense", 1, new String[] {"boolean"});
digester.addCallParam(
           "quickmenu-config/entry/visibility", 0, "sense");
 
In this case, configuring the CallMethodRule to invoke a method with a 
primitive data type as a parameter fails.  The commented out version 
using the Boolean wrapper object succeeds.  (NOTE: The destination 
object has the method with both signatures). 
 
Stack trace from my code:
========================= 
End event threw exception
java.lang.NullPointerException:
       at org.apache.struts.util.BeanUtils.convert(BeanUtils.java:131)
       at org.apache.struts.digester.CallMethodRule.end(CallMethodRule.java:226)
       at org.apache.struts.digester.Digester.endElement(Digester.java:373)
       at com.sun.xml.parser.Parser.maybeElement(Parser.java:1413)
       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.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 loadQuickmenu.readConfig(loadQuickmenu.java:32)
       at loadQuickmenu.main(loadQuickmenu.java:41)

To correct this issue in struts, add new method to BeanUtils.java [Class
forName(String classname)] which defers to/mirrors the version in Class
but 
also handles primitive data types.  Modify constructor in 
org/apache/struts/digester/CallMethodRule.java to call 
BeanUtils.forName(String) rather than Class.forName(String) to convert 
the className to a Class Object.  

The updated files are attached.
 
e
-- 
_______________________________________________________________________
Elod Horvath ('e')       /      ITFAIS Records (http://www.itfais.com/)