I am trying to figure out which JAR libraries, out of a total of 83 JARs, are actually being used by a group of 12 Java EE/Spring projects. All JARs are under one EAR. Development is done in Eclipse and the build tool is Ant. All projects run on WebSphere Application Server 6.0.
This question: How to figure out used JARs?
points to this one: How to analyse which jar file is used in a Java program?
which recommends invoking the java
executable with the -verbose:class
argument, but if this would be useful here, how do I do this in the case where the projects are running on my local WAS 6.0?
This question seems to point more in the right direction: How to find which jars and in what order are loaded by a classloader?
However, I'm not familiar with how a class loader works, how to tell what my class loader instance is (a reply indicates that URLClassLoader has a getURLs()
method that provides access to a list of jars/directories), and if my class loader instance is not URLClassLoader, where do I go from there?
Turn on verbose class loading (as suggested by dims)
Look at the admin console and you will see a class loader viewer which shows you the required information.
Class loader has a standard hierarchy that it uses to load the classes.
Have a look at this: http://www-01.ibm.com/support/docview.wss?uid=swg27023549&aid=1
This presentation give you a very good intro to how things work in the WebSphere environment.
HTH
Manglu
For WebSphere 6.1, you can use the "-verbose:dynload" option (see page 52 of the WebSphere Application Server V6.1: Classloader Problem Determination Redbook). You will see the output in native_stderr.log
You could try using something like http://www.jboss.org/tattletale. This can tell you which jars are not being used.
Generic answer to this question could be tricky. As Java loads classes dynamically some jars/classes might not be loaded unless all functionality of your program is exercised (think about Class.forName("foo") as trivial example). Therefore any kind of static dependency analysis might not present 100% complete picture, you might have to analyze running application as it executes, preferably hitting all code branches.
As a rough first approximation, to see if there are jars that not being opened at all, you might try to look at list of open files for webSphere process, as reported by your OS ('lsof' on Unix) when your application is running. If jar is not listed as opened it's pretty good indication that it's not being loaded/used but reverse not necessary true as Websphere could scan jars for annotations etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With