We are working on a dynamic class loader project and trying to invoke a method in a dynamically loaded class via URLClassLoader, It works pretty well when it's run in Eclipse, so the invoking and dynamically loaded classes are bundled in to two different jars then deployed into Server because it’s part of requirement to split into two jars.
NoSuchMethodException exception thrown when calling Method.invoke() using reflection api.
We have verified Jar and it confirms methods being invoked is present in class.
Here is sample code..
import com.altova.io.Input;
import com.altova.io.FileInput;
Input sourceInput = new FileInput(inputFileFullPath);
Class oneParam[] = { Input.class };
// Class<?> mapClass = Class.forName("com.sample.test.TrackingService");
Object mapObj = mapClass.newInstance();
Method method = mapClass.getDeclaredMethod(RUN, oneParam);
li = (List) method.invoke(mapObj, sourceInput);
Exception is : java.lang.NoSuchMethodException: com.sample.test.TrackingService.run(com.altova.io.Input)
Only difference I doubt is Input(in method signature) and FileInput (in the parameter).
It works well in Eclipse, but not in server. It's tested with JDK 1.6 & 1.7, but server runs on jdk 1.7
Aucun commentaire:
Enregistrer un commentaire