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).
2 Answers
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.
Comments
You could combine this answer with the following to get near to every classloader.
Thread.getAllStackTraces().keySet() //Get all active threads
.stream()
.map(thread -> thread.getContextClassLoader()) //Get the classloader of the thread (may be null)
.filter(Objects::nonNull) //Filter out every null object from the stream
.toList()