24

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 2

8

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.