commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Álvaro Barge <>
Subject NullPointerException when performing addCallMethod
Date Wed, 05 Jun 2002 18:01:36 GMT

I am trying to parse an XML document that has a numeric attribute (size) 
in one of its elements. I was trying to invoke a setNumber(int value) 
method in the bean by adding a CallMethodRule and a CallParamRule:

                     "setNumber", 1, new String[] {"java.lang.Integer"});
digester.addCallParam("result/stats", 0, "size");

This code throws a NullPointerException in the CallMethodRule(String 
methodName,int paramCount, String paramTypes[]) constructor (in line 
229). (I am using digester 1.2 over Linux with the Sun Java 1.3.1).I 
have been looking for the error cause, and I have found that the 
constructor uses a "digester.getClassLoader().load..." method when the 
paramTypes array specified is not empty.

Well, looking at the digester source code, it seems that the 
CallMethodRule is created in the addCallMethod method, so in that 
constructor the digester object has not been set (the setDigester method 
is invoked in the addRule method of the Digester class, after creating 
the CallMethodRule). So, IMHO, the NullPointerException will appear 
whenever a non-empty paramTypes array is specified in the CallMethodRule 
creation, because the Digester object will never be set in that point of 
the program. Do you think that this is correct?

I have been also looking at the RuleTestCase, and there are no tests 
checking this constructor with a non-empty paramTypes array, so this 
situation is not tested.

In my opinion, the ClassLoader must be obtained using another object and 
a new test line should be added in the TestCase.

What do you think about this? Is this correct? Has anybody had this 
problem before?


Álvaro Barge

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message