Analysing jar dependencies

Something like 2 months ago I wrote a post on how different classloaders can potentially cause you problems if you’re not that careful on where your libs are loaded from. Well, I’ve just had to face another issue of that type, with a library of mine loaded from the bootstrap classloader and referencing a class from servlet API that I don’t want to be loaded by that classloader too. The easy solution of course would have been to pull my lib out of the endorsed dir (the one the bootstrap classloader loads libs from), but how could I be sure that I did not break anything in my app? Besides running tests, I finally decided to give JBoss Tattletale a try… I saw all the hype around it when it was released some month ago, but I did not have the chance to use it for a practical issue before.

Well, in less than five minutes I checked out he project, built it and ran it against my endorsed lib dir. I got a report and some graphs basically showing no libraries in that dir (hence loaded by the bootstrap classloader) where directly depending on my library, thus it’s safe to pull it out of the endorsed dir. The easy solution was indeed OK and thanks to this tool I have a theoretical proof of that ;-)

Take a look at JBoss Tattletale, it’s really a cool tool. Perhaps you can start from its author’s blog: http://blog.hibernate.org/11166.lace