Using Java 1.5 if we have a service with a method that receives a primitive type as a parameter then the invocation fails to discover such method because it's looking for a method with the signature of the corresponding wrapper. Example:
- method public run(int i) in a service named SampleService.
invoking the service with execute(null, "SampleService", args) where args = {1} (or {new Integer(1)}) will fail with something similar to this:
Exception in thread "main" pt.utl.ist.berserk.logic.serviceManager.exceptions.ServiceManagerException: Cannot execute method run of service: class SampleService: java.lang.NoSuchMethodException: SampleService.run(java.lang.Integer)
at pt.utl.ist.berserk.logic.serviceManager.ServiceInvoker.doInvocation(ServiceInvoker.java:152)
at pt.utl.ist.berserk.logic.serviceManager.SimpleServiceInvoker.invoke(SimpleServiceInvoker.java:67)
at pt.utl.ist.berserk.logic.serviceManager.ServiceManager.execute(ServiceManager.java:238)
at pt.utl.ist.berserk.logic.serviceManager.ServiceManager.execute(ServiceManager.java:217)
Logged In: YES
user_id=900176
IMPORTANT CORRECTION: I now have no reason to believe that this is only a java 1.5 problem. The fact is that it only occurs if there are two methods with the same name and the method we are invoking uses primitive type or interfaces. Consider this method in a service:
public void someOtherMethod(Integer age, String name, List battles, boolean deceased);
boolean is primitive. However it will work fine for the invocation whether we set the fourth parameter as "true" or "new Boolean(true)" in the parameters array.
If we add this method (parameters are irrelevant - as long as signature is different of course):
public void someOtherMethod();
then the invocation of the first method will no longer work unless we define Boolean instead of boolean in the signature. Moreover, it will still fail because "Collection" is an interface and we will need to write something like "Vector" instead, which is really ugly!