commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chad Woolley <li...@thewoolleyweb.com>
Subject Re: Digester / BeanUtils - No Such Accessible Method error
Date Thu, 12 Feb 2004 20:32:42 GMT
Hello,

I never got any bites on this, so here it is again with all the info in 
one place.

I'd really like to resolve this, as it is preventing me from using 
Digester.  I guess I should try to write a failing unit test for it and 
submit it as a bug, but I'm not sure whether it is a problem with 
BeanUtils or Digester.  It really appears to be the JDK 
Method.getParameterTypes() that is behaving incorrectly, but that seems 
unlikely, it is probably some issue with another tool or my environment.

Thanks,
Chad


 > Hello,
 >
 > I am trying to use Digester, and am getting an exception "No such 
accessible method" when using Digester.addSetNext(...).
 >
 > I have debugged this down to the 
"MethodUtils.getMatchingAccessibleMethod()" method in BeanUtils.
 >
 > The problem appears to be on line 616:
 >
 > if (!isAssignmentCompatible(methodsParams[n], parameterTypes[n])) {
 >
 > If I use the Eclipse debugger to inspect these two arguments, I see 
that parameterTypes[n] has the Class data correctly populated 
(declaredConstructors, declaredMethods, etc).
 >
 > However, methodParams[n] has null for all of these properties of the 
Class.  This means that in MethodUtils.isAssignmentCompatible(), the 
isAssignableFrom() call returns false, even though the names of the 
classes are identical.
 >
 > The original value of methodParams[n] comes from this line just above:
 > Class[] methodsParams = methods[i].getParameterTypes();
 >
 > I have searched for the answer to this problem, but all other 
references seem to deal with default-access superclasses, which I don't 
have.
 > Both the parent and child objects on the stack when I call 
Digester.addSetNext() are plain public java objects, with no 
superclasses, and all public methods.
 >
 > It seems like this should be working fine, it's just that the Class 
object that is created from getParameterTypes() has all null fields 
instead of the being properly populated.
 >
 > I can provide any additional information that is required.  This is 
an open source project, so the problem can be recreated via my unit 
tests, if you want to look at it.
 >
 > Thanks,
 > Chad




> José Antonio Pérez Testa wrote:
> 
>> Can you send the rules and an extract of the code you are using ?
> 
> 
> Sure.  If you want to actually see the error happen, I can give you 
> instructions to check out my source and run the unit test.
> 
> Here is the XML:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <virtualmock xmlns="http://www.virtualmock.org/virtualmock.xsd">
>     <excluded-classes>
>         <exclusion-pattern>test.*</exclusion-pattern>
>     </excluded-classes>
>     <rules>
>         <rule>
>             
> <rule-type>org.virtualmock.rule.AllRecordedCallsMustBeInvokedRule</rule-type>

> 
>         </rule>
>     </rules>
> </virtualmock>
> 
> -------------------------------------
> 
> Here is the Digester:
> 
>         vmConfig = new VMConfig();
> 
>         digester.push(vmConfig);
>         digester.setValidating(validate);
> 
>         
> digester.addCallMethod("virtualmock/excluded-classes/exclusion-pattern",
>             "addClassExclusionPattern", 0);
> 
>         digester.addObjectCreate("virtualmock/rules/rule", 
> RuleConfig.class);
>         digester.addBeanPropertySetter("virtualmock/rules/rule/rule-type",
>             "ruleType");
>         digester.addSetNext("virtualmock/rules/rule", "addRuleConfig", 
> "org.virtualmock.configuration.RuleConfig");
> 
>         try {
>             digester.parse(inputStream);
>         } catch (SAXException saxException) {
> 
> -------------------------------------
> 
> Here is the Parent object:
> 
> public class VMConfig {
>     private List classExclusionPatterns = null;
>     private List ruleConfigs = null;
> 
>     public VMConfig() {
>         classExclusionPatterns = new ArrayList();
>         ruleConfigs = new ArrayList();
>     }
> 
>     public List getClassExclusionPatterns() {
>         return classExclusionPatterns;
>     }
> 
>     public List getRuleConfigs() {
>         return ruleConfigs;
>     }
> 
>     public void addClassExclusionPattern(String classExclusionPattern) {
>         classExclusionPatterns.add(classExclusionPattern);
>     }
> 
>     public void addRuleConfig(RuleConfig ruleConfig) {
>         ruleConfigs.add(ruleConfig);
>     }
> }
> 
> -------------------------------------
> 
> Here is the Child object:
> 
> public class RuleConfig {
>     private String ruleType = null;
> 
>     public void setRuleType(String ruleType) {
>         this.ruleType = ruleType;
>     }
> 
>     public String getRuleType() {
>         return ruleType;
>     }
> 
>     public RuleConfig() {
>         super();
>     }
> 
> }
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message