Last updated Apr 2, 2024

How do I check which jar file a class file belong to?

How do I check which Jar file a class file belong to?

Knowing a jar file where a stack trace originates from can be handy when troubleshooting for library conflict. If you want to find out, this can be easily done using user macros.

For example:

You can copy and paste the following code, which is the same as the screenshot above:

1
2
<pre>$action.getClass().getClassLoader().loadClass("org.apache.commons.lang.StringUtils").getProtectionDomain().toString()</pre>

If the macro is run, it will print the path of the loaded jar file in your application server ie. the above user macro will print the file path to the jar file where org.apache.commons.lang.StringUtils class belongs.

Rate this page: