Hi Himasha, Have you tried using JCL frame work. This framework support Class loading from different ways as URLs, File input streams , jar files from a folder. Hope this is helpful.
https://github.com/kamranzafar/JCL/blob/master/README.textile Madhuranga Sampath Bandara Software Engineer WSO2, Inc.;http://wso2.com/ lean.enterprise.middleware Mobile: +94722241065 On Wed, May 13, 2015 at 10:47 AM, Himasha Guruge <[email protected]> wrote: > Hi All, > > I'm working on a requirement where jars need to be dynamically loaded to the > classpath in order to prevent server restarting. I was able to load the jar > and load the required class by using a URLClassLoader. But at the place > where I'm using the implementation of this class(ex:foo.a), an error is > thrown saying "cannot instantiate foo.a" . I assume this is happening > because this class is initially implementing an interface (javaDelegate) and > this interface is not available in the classpath. > > What I have done so far is getting the current system class loader, and > within my custom class loader I'm adding the jar path as a url. > > URLClassLoader loader = (URLClassLoader)ClassLoader.getSystemClassLoader(); > MyClassLoader loader1 = new MyClassLoader(loader.getURLs()); > loader1.addURL(new URL("jar","","file:"+artifactLocation+"!/")); > > Any suggestions on how to resolve this issue/ better method of handling > dynamic loading will be appreciated. > > Thanks, > > Himasha Guruge > Software Engineer > WSO2 Inc. > Mobile: +94 777459299 > [email protected] > > _______________________________________________ > Dev mailing list > [email protected] > http://wso2.org/cgi-bin/mailman/listinfo/dev > _______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
