Spring example Petclinic on Tomcat 6

2007/09/20

If you try to deploy one of the Spring 2 samples included in the Spring framework source distribution – Petclinic on Tomcat 6 (6.0.14), the web application does not get loaded and fails with errror. The cause is the ClassNotFound exception for the class org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader, more precisely:


SEVERE: LifecycleException
java.lang.ClassNotFoundException: org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)

The message is a bit confusing, because after peeking into spring.jar you’ll find out that class in question is it is contained in the jar. What is happening is “classical” issue of classloaders and the who-loads-what problem.

Fortunately, solution is very easy: what helped was copying the spring-tomcat-weaver.jar from Spring distribution into TOMCAT_HOME/lib directory and restarting the container.

This thread was helpful to find out the cause. It may also be mentioned in the documentation, alas – I did not get to reading it yet :-).

Advertisements