java - Unable to load classes in a jar file -
i working on project designed take plugins. in order load plugins jar file, using classloader
. code using load plugins.
urlclassloader loader = urlclassloader.newinstance(new url[] {pluginjar.touri().tourl()}, this.getclass().getclassloader()); seek { class<?> clazz= class.forname("msciplugin.plugindriver", true, loader); constructor<?> constructor=clazz.getconstructor(programmanager.class); msciplugin plugin=(msciplugin) constructor.newinstance(programmanager); plugins.add(plugin); plugin.addmscipluginlistener(this); this.pluginadded(plugin); } grab (exception e) { e.printstacktrace(); homecoming false; } loader.close();
when run program, able load test plugin created, later in program, inquire plugin perform operation, uses class plugin jar not used initially. programme throws noclassdeffounderror
caused classnotfoundexception
exception in thread "awt-eventqueue-0" java.lang.noclassdeffounderror: msciplugin/timeutils @ msciplugin.servercontrollerconfigurationwindow.refreasheditor(servercontrollerconfigurationwindow.java:195) @ msciplugin.servercontrollerconfigurationwindow.valuechanged(servercontrollerconfigurationwindow.java:299) @ javax.swing.jlist.fireselectionvaluechanged(unknown source) @ javax.swing.jlist$listselectionhandler.valuechanged(unknown source) @ javax.swing.defaultlistselectionmodel.firevaluechanged(unknown source) @ javax.swing.defaultlistselectionmodel.firevaluechanged(unknown source) @ javax.swing.defaultlistselectionmodel.firevaluechanged(unknown source) @ javax.swing.defaultlistselectionmodel.changeselection(unknown source) @ javax.swing.defaultlistselectionmodel.changeselection(unknown source) @ javax.swing.defaultlistselectionmodel.setselectioninterval(unknown source) @ javax.swing.jlist.setselectioninterval(unknown source) @ javax.swing.plaf.basic.basiclistui$handler.adjustselection(unknown source) @ javax.swing.plaf.basic.basiclistui$handler.mousepressed(unknown source) @ java.awt.awteventmulticaster.mousepressed(unknown source) @ java.awt.component.processmouseevent(unknown source) @ javax.swing.jcomponent.processmouseevent(unknown source) @ java.awt.component.processevent(unknown source) @ java.awt.container.processevent(unknown source) @ java.awt.component.dispatcheventimpl(unknown source) @ java.awt.container.dispatcheventimpl(unknown source) @ java.awt.component.dispatchevent(unknown source) @ java.awt.lightweightdispatcher.retargetmouseevent(unknown source) @ java.awt.lightweightdispatcher.processmouseevent(unknown source) @ java.awt.lightweightdispatcher.dispatchevent(unknown source) @ java.awt.container.dispatcheventimpl(unknown source) @ java.awt.window.dispatcheventimpl(unknown source) @ java.awt.component.dispatchevent(unknown source) @ java.awt.eventqueue.dispatcheventimpl(unknown source) @ java.awt.eventqueue.access$400(unknown source) @ java.awt.eventqueue$3.run(unknown source) @ java.awt.eventqueue$3.run(unknown source) @ java.security.accesscontroller.doprivileged(native method) @ java.security.protectiondomain$1.dointersectionprivilege(unknown source) @ java.security.protectiondomain$1.dointersectionprivilege(unknown source) @ java.awt.eventqueue$4.run(unknown source) @ java.awt.eventqueue$4.run(unknown source) @ java.security.accesscontroller.doprivileged(native method) @ java.security.protectiondomain$1.dointersectionprivilege(unknown source) @ java.awt.eventqueue.dispatchevent(unknown source) @ java.awt.eventdispatchthread.pumponeeventforfilters(unknown source) @ java.awt.eventdispatchthread.pumpeventsforfilter(unknown source) @ java.awt.eventdispatchthread.pumpeventsforhierarchy(unknown source) @ java.awt.eventdispatchthread.pumpevents(unknown source) @ java.awt.eventdispatchthread.pumpevents(unknown source) @ java.awt.eventdispatchthread.run(unknown source) caused by: java.lang.classnotfoundexception: msciplugin.timeutils @ java.net.urlclassloader$1.run(unknown source) @ java.net.urlclassloader$1.run(unknown source) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(unknown source) @ java.lang.classloader.loadclass(unknown source) @ java.net.factoryurlclassloader.loadclass(unknown source) @ java.lang.classloader.loadclass(unknown source) ... 45 more
any help appreciated.
i figured out problem was. when loading class msciplugin.plugindriver
urlclassloader
not loading other classes needed. solved problem loading classes in jar file. used method here find of classes in jar file.
java plugins classloader
No comments:
Post a Comment