Check if the jar file is loaded?
I have a custom jar file in tomcat lib / folder. From my knowledge, any jar file in this folder will be loaded on startup.
Is there anyway I can check if a specific jar file is loaded or not?
I am running tomcat-6.0.35.A on unix rhel5.
+4
latestVersion
source
to share
2 answers
I think I've seen which jars are opened at startup in one of the Tomcat log files. If it weren't for me, I could think of two possible alternatives:
- Add
-verbose:class
inJAVA_OPTS
Tomcat startup scripts. It should print the classes as they are loaded by the JVM (a lot of output). Grep log file (or standardstdout
) to find if classes are listed from your jar - Use the Linux lsof command to view the files opened by the Tomcat process.
+17
maximdim
source
to share
The boxes are not actually loaded at startup. But Tomcat classloader loads classes from these jars. You can check if any class is available from the jar:
- trying to load this class from your code eg.
getClass().getClassloader().loadClass(className)
- trying to load a class as a resource like
getClass().getResource("/" + className.replace('.', '/') + ".class")
In the second case, you must have the name or your jar file in the url returned getResource()
.
+2
Eugene Kuleshov
source
to share