Reflection et runnable Jar
Bonjour,
J'ai écrit un code qui fait appel à un endroit à une instanciation dynamique :
Code:
Firm newFirm = (Firm) Class.forName(className, false, ClassLoader.getSystemClassLoader()).getConstructor(String.class, CapitalOwner.class, Map.class).newInstance(name, owner, map);
Ce code fonctionne correctement dans Eclipse.
Par contre, si je l'exporte comme Jar exécutable, à l'exécution j'obtiens l'erreur suivante:
Citation:
java.lang.NoSuchMethodException: agents.firms.FirmE0.<init>(java.lang.String, agents.roles.CapitalOwner, java.util.Map)
at java.lang.Class.getConstructor0(Class.java:2706)
at java.lang.Class.getConstructor(Class.java:1657)
...
Exception in thread "main"
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Quelqu'un saurait-il m'expliquer d'où peut venir ce problème ?
Merci d'avance pour votre aide.