I am trying to see where a first party class and third-party class are loaded from say a websphere liberty as well as apache tomcat. When I use -verbose:class, I see a bunch of paths but don't see the path in question. It looks like liberty related paths but not the third-party path was looking for.
For example, let's say the class is just org/apache/loggger/Logger.class where is that class?
I tried Reflections library, was sure if that was the right use case.
I tried these approaches below, didn't find what was looking for. The class is there at compile time. Also couldn't find any third-party classes this way.
final ClassLoader loader = ServletVers2.class.getClassLoader();
System.out.println(loader.getResource("com/ca/services/servlet/ServletVers2.class"));
System.out.println(loader.getResource("com/ca/apps/shared/utils/BuildVersion.class"));
final ClassLoader classloader2 = ClassLoader.getSystemClassLoader();
final ClassLoader classloader3 = ClassLoader.getSystemClassLoader().getParent();
System.out.println(loader.getResource("org/apache/logging/log4j/LogManager.class"));
System.out.println(loader.getResource("org/apache/log4j/Logger.class"));
System.out.println(classloader2.getResource("org/apache/logging/log4j/LogManager.class"));
System.out.println(classloader2.getResource("org/apache/log4j/Logger.class"));
System.out.println(classloader3.getResource("org/apache/logging/log4j/LogManager.class"));
System.out.println(classloader3.getResource("org/apache/log4j/Logger.class"));
Reflections reflections = new Reflections("com.apps.shared.utils.BuildVersion", new SubTypesScanner(false));
Per the comments, this should work. It is not entirely what I was looking for but will continue with this.
Logger.class.getResource("Logger.class"). Alternatively, org.apache.log4j.Logger.class.getClassLoader().getResource( "org/apache/log4j/Logger.class")