Search code examples
javatomcat6classloader

Finding what jars are in the classloader for a specific application in tomcat6


Scenario

I have a situation where spring is finding two versions of a class.

org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [org.springframework.scheduling.quartz.SchedulerFactoryBean] is defined: expected single matching bean but found 2:

My problem is finding where the duplicate class is coming from.

Usually, I'd just use jdgui to open/de-compile all jars in the web-inf/lib and tomcat/lib folders and do a type search for the duplicate class.

The trick is that I am using sysdeo plugin with eclipse, and maven, and several war projects, so things are a little more complex than that.

My Question Is there any GUI or open source library that I can use to find the location of jars for a particular class that works with Tomcat6.

In the past, I have used a very nice tool with IBM Websphere's administration console that allows me to browse the classloader tree.

Failing advice from my peers, I guess I'll need to write something myself.


Solution

  • Thanks to the help in comments, I was able to come up with the following solution.

    The module with my spring config is being compiled into to the war's lib folder (i.e. /target/xxxx-war/WEB-INF/lib/myspringmodule.jar)

    Sysdeo tomcat folder is configured to add the /myspringmodule/target/classes to the classpath, thus allowing me to simply re-compile in eclipse. This was effectively adding two duplicate spring configs on the class path triggering annotation scanning twice, and thus two objects.

    My solution is to create a maven profile for local builds in eclipse that I use to exclude the two jars.