WILDFLY - Loading jar dynamically java.lang.ClassNotFoundException -
i have ear deployed in wildfly , i'm loading jar source code:
file file = new file("c:\\xxxx\\xxxx\\processtest.jar"); string lcstr = "com.package.test.testprocess"; urlclassloader cl = urlclassloader.newinstance(new url[]{file.tourl()}); class<?> loadedclass; try { loadedclass = cl.loadclass(lcstr); iprocess data = (iprocess)loadedclass.newinstance(); data.start(); } catch (exception e) { e.printstacktrace(); }
the testprocess class implements iprocess loaded in jar ear.
when run server code , class being casted receive:
java.lang.noclassdeffounderror: com/package/test/process/iprocess
if added interface in jar i'm loading problem castexception because com/package/test/process/iprocess loaded wildfly different of loaded jar.
i need receive iprocess (casting object), because solution call directly method mehtod.invoke it's not solution problem.
thanks in advanced.
with tip works perfectly:
urlclassloader.newinstance(new url[]{file.tourl()}, iprocess.class.getclassloader())
thanks steve c!
Comments
Post a Comment