javatomcattomcat6classloadercontextclassloader

Custom Tomcat Webapp ClassLoader


I'm trying to implement a custom classloader for tomcat. My first attempt yielded a class cast exception (apparently, tomcat tries to cast my loader to org.apache.catalina.loader.WebappLoader). Fine, I extended WebappLoader and added the catalina.jar to my buildpath.

Now I'm ready to deploy (I think). I'm getting this error:

SEVERE: Catalina.start: LifecycleException: start: : java.lang.NoClassDefFoundError: org/apache/catalina/loader/WebappLoader

Tomcat comes with catalina.jar to run, so I'm 99.9% sure it's already loaded into tomcat. I verified this by checking /server/lib/catalina.jar, which does contain the apache WebappLoader. Furthermore, manually linking another catalina.jar in creates a whole mess of problems, as expected.

I'm confused. Any tips would be hot.

Thanks!

Update: Interestingly, the same thing on tomcat6 (extending WebappLoader; worked on tomcat5.5), still causes a ClassCastException. Sounds to me like the class performing the cast was loaded using a different loader from the one which loaded my class. I don't see how I would have control over that anyway, unless maybe another missing tomcat config somewhere? Any ideas for tomcat6 either?


Solution

  • Maybe I'm being dense, but I think that should be WebappClassLoader, not WebappLoader. The import looks ok though.