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
himas...@wso2.com
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to