Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

By default, Tomcat prevents webapps from loading several .jars which are part of the Tomcat distribution (eg the servlet and JSP APIs) - is it possible to configure others to also be excluded?

If it can't be done with configuration alone, does Tomcat provide any extension points for resource validation?

I want to use shared logging libraries, and need to make sure that an errant app doesn't clobber the configuration.

Example

This is what I'm referring to (from Tomcat startup log):

Oct 1, 2011 5:53:40 AM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(D:\tomcat\myapp\WEB-INF\lib\servlet-api.jar) - jar not loaded.
See Servlet Spec 2.3, section 9.7.2.
Offending class: javax/servlet/Servlet.class
share|improve this question
    
I do not think tomcat Exclude any thing as such just a matter of classloading sequence which jar comes first in classpath . You are may be after this .stackoverflow.com/questions/267953/managing-libraries-in-tomcat –  Shahzeb Oct 1 '11 at 9:49
    
@Shahzeb: I added an example. This isn't really about how the different classloaders interact - I want to be able to validate the resources that webapps try to load. –  Dmitri Oct 1 '11 at 10:02
add comment

migrated from stackoverflow.com Oct 3 '11 at 11:52

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 5 down vote accepted

You check/filter what web apps load using a custom loader extending from org.apache.catalina.loader.WebappClassLoader as mentioned in the Tomcat documentation.

Check out Tomcat's implementation (7.0.19) of the standard WebAppClassLoader that implements the filtering of javax.servlet.Servlet to get started. It's probably enough to override that class and just put some more entries into the protected String[] fields triggers and packageTriggers.

share|improve this answer
1  
Of course, your custom WebappClassLoader should go into its own JAR in TOMCAT_HOME/lib away from your web apps, just to state the obvious :) –  Philipp Reichart Oct 1 '11 at 10:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.