I have a class that i defined in system.jar and i loaded it from classpatch. But in bootstrap.jar which i put in $JAVA_HOME/jre/lib/ext. I need to load a class which was defined in system.jar. How can i load it?
I known. When Tomcat is started, it creates a set of class loaders that are organized into the following parent-child relationships, where the parent class loader is above the child class loader:
Bootstrap
|
System
|
Common
/ \
Webapp1 Webapp2 ...
No have ways to load class with my idea?
Thanks,
The class loader hierarchy is
Bootstrap Loader → Extension Loader → Application Loader.And, despite it’s name,
ClassLoader.getSystemClassLoader()will return the application loader which will be the one which resolves classes using the supplied userCLASSPATH.So from a class contained in
bootstrap.jar(which will be loaded by the extension loader when placed injre/lib/ext) you can useClassLoader.getSystemClassLoader() .loadClass("class.within.your.classpath")to load the class fromsystem.jar.As a side note, in this typical setup, the expression
ClassLoader.getSystemClassLoader().getParent()==MyClass.class.getClassLoader()will evaluate totrueifMyClasshas been loader by the extension loader.