Hi Himasha, This might be helpful for you [1] - http://stackoverflow.com/questions/9433003/how-to-load-a-class-which-implements-a-interface-from-a-jar-file-at-runtime
Thanks 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* > WS*O2* *Inc.* > Mobile: +94 777459299 > [email protected] > > _______________________________________________ > Dev mailing list > [email protected] > http://wso2.org/cgi-bin/mailman/listinfo/dev > > -- Thusitha Dayaratne Software Engineer WSO2 Inc. - lean . enterprise . middleware | wso2.com Mobile +94712756809 Blog alokayasoya.blogspot.com About http://about.me/thusithathilina
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
