I am trying to load a class present in a war file in tomcat from a class in a jar in tomcat lib. I am doing this using Class.forname("myclass") but the application is throwing class not found exception. i guess this is because the webapp will have its own class loader. can someone suggest how to fix this
Instantiating a tomcat WEB-INF\class\myclass from tomcat lib using classloader
106 Views Asked by Subhomoy Sikdar At
2
This is by design - you can't do that. With the hierarchical classloaders that tomcat is using, you don't have a chance to load a class that's contained a webapp from a class loaded from the global classpath unless you build your own classloading mechanism - which I wouldn't recommend.
I'd rather like to know what problem you're trying to solve with this solution attempt. I can't think of any underlying problem where this would be the right solution for.