commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frank W. Zammetti" <fzli...@omnytex.com>
Subject Re: [beanutils] Problem with MethodUtils.invokeExactMethod
Date Wed, 09 Mar 2005 00:05:48 GMT
Well, I don't know what the problem was, but I was able to solve it by 
NOT using invokeExactMethod.  I did it the old-fashioned manual way:

String setupClass = "com.omnytex.setupexample.setups.SetupClass1";
String setupMethod = "setupMethod1";
Object setupClassObj = RequestUtils.applicationInstance(setupClass);
Class c = Class.forName(setupClass);
Class pTypes[] = new Class[1];
pTypes[0] = Class.forName("javax.servlet.http.HttpServletRequest");
Method m = c.getMethod(setupMethod, pTypes);
Object args[] = new Object[1];
args[0] = request;
m.invoke(setupClassObj, arglist);

I'd frankly prefer to use invokeExactMethod, so if anyone can see what 
went wrong originally, I'd be greatful!

Frank

Frank W. Zammetti wrote:
> Hello...
> 
> I'm trying to use MethodUtils.invokeExactMethod, and I keep receiving:
> 
> java.lang.NoSuchMethodException: No such accessible method: 
> setupMethod1() on object: com.omnytex.setupexample.setups.SetupClass1
> 
> Here's the pertinent code:
> 
> String setupClass = "com.omnytex.setupexample.setups.SetupClass1";
> String setupMethod = "setupMethod1";
> Object setupClassObj = RequestUtils.applicationInstance(setupClass);
> MethodUtils.invokeExactMethod(setupClassObj, setupMethod, request);
> 
> request is an HttpServletRequest object.  Here's the code for SetupClass1:
> 
> package com.omnytex.setupexample.setups;
> import javax.servlet.http.HttpServletRequest;
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> public class SetupClass1 {
>   private static Log log = LogFactory.getLog(SetupClass1.class);
>   public void setupMethod1(HttpServletRequest request) {
>     log.info("setupMethod1() - Setting request attribute...");
>     request.setAttribute("c1m1", "c1m1_value");
>     log.info("setupMethod1() - Done!");
>   }
> }
> 
> Clearly, there is in fact a setupMethod1() method.  I have verified that 
> setupClassObj is in fact a valid object of the correct type, so its not 
> an instantiation problem (would have expected a different exception if 
> it was anyway).
> 
> My only guess is that I'm somehow not using the argument portion of the 
> invokeExactMethod() call properly, but I don't see what the problem 
> specifically might be.
> 
> Any ideas?  Thanks!
> 

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com


---------------------------------------------------------------------
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