Eyal Hirsch wrote:
>Hi Jim,
> I've tried this with a simple java.lang.String
>object as well but the same result happened
>I still get a NoSuchMethodException thrown.
>
>This is a debug dump using reflection on the bean
>I've retrieved :
>
>After beanInstance.getClass() - WebECom.Products._Product_Stub
>
>Name ( 0 ) - equals
>Params :
>0 - java.lang.Object
>
>Return type -boolean
>Modifiers - 1Public
>
>.....
>
>Name ( 39 ) - showAllProducts
>Params :
>0 - WebECom.Utils.RequestWrapper
>
>Return type -java.lang.String
>Modifiers - 1Public
>
>
>The showAllProducts is the method i'm tring
>to call with getMethod and fail.
>
>Any suggestions what am I doing wrong here ? ? ?
>
>Thanks a lot,
> eyal.
>
Hello,
Are you sure that the class in the methodBeanTypes and the class used as
parameter in your classData method are the same, I mean, are they loaded
by the same class loader?
Two Class objects needs more than having the same name to be considered
equals in the JVM. They must also be loaded by the same class loader.
If you have a method in a class that takes a parameter of class C1 known
through the class loader cl1 and you are looking for that method using
another copy of class C1 loaded by another class loader (cl2), the method
will not be found because C1 loaded by class loader cl1 is not the same
class as C1 loaded by class loader cl2.
This may explain why it work in a regular class (all classes are loaded by
the same class loader) while it is not working with a servlet (usually more
than one class loader is used in web servers).
One way to make sure is to compare the class in the methodBeanTypes with the
class used as parameter for the method. If they are not equal and have the
same name, you can compare the class loaders of the classes to see if they
are the same.
If they are not the same, then you will have to revisit your class loading
strategy.
Regards,
Benoit Tremblay (Clea informatique)
at Ericsson Research Canada
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".