Depends on delegate
attribute
I haven't tried any of this. But it seems to hinge on value of the boolean delegate
attribute.
And the way I read https://tomcat.apache.org/tomcat-10.0-doc/class-loader-howto.html#Class_Loader_Definitions is this:
For any webapp there are FOUR class loaders: bootstrap, system, common, webapp.
- By default the boolean
delegate
attribute is not specified and will default to false
- => order of class loaders:
bootstrap
, webapp
, system
, common
- => Your webapp's JAR wins.
- If, and only if, you explicitly specify
<Loader delegate="true"/>
- => order of class loaders:
bootstrap
, system
, common
, webapp
- =>
common
takes JARs from $CATALINA_BASE and $CATALINA_HOME
- => Tomcat's JAR wins.
Further reading
Added info: This here is the documentation for the "delegate" attribute itself.
I find this slightly confusing, but it seems that Tomcat's default is to NOT follow Java's default. (Not sure wherever Java's default "delegation model" may have been defined.)
Quote from https://tomcat.apache.org/tomcat-10.0-doc/config/loader.html#Common_Attributes
(Formatting changed for emphasis.)
Set to true if you want the class loader to follow the standard Java2 delegation model, and attempt to load classes from parent class
loaders before looking inside the web application.
Set to false (the default) to have the class loader look inside the web application first, before asking parent class loaders to find
requested classes or resources.