Is it possible to get a list of all class loaders in a JVM or at least all class loaders associated with web apps in a Java EE Server (WebLogic in my case).
When the JVM is started, three class loaders are used: Bootstrap class loader. Extensions class loader. System class loader.
You can get all classpath roots by passing an empty String into ClassLoader#getResources() . Enumeration<URL> roots = classLoader. getResources("");
To know the ClassLoader that loads a class the getClassLoader() method is used. All classes are loaded based on their names and if any of these classes are not found then it returns a NoClassDefFoundError or ClassNotFoundException.
Class loaders are responsible for loading Java classes dynamically to the JVM (Java Virtual Machine) during runtime. They're also part of the JRE (Java Runtime Environment). Therefore, the JVM doesn't need to know about the underlying files or file systems in order to run Java programs thanks to class loaders.
There are good overviews on the class loader hierarchy at:
Archived version of http://e-docs.bea.com/wls/docs81/programming/classloading.html
http://weblogic.sys-con.com/node/42876
You can use
ClassLoader.getParent()
to walk through you current application's applications resolution tree, but you really can't look through the children app's class loaders.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With