Control the classpath ordering of jars in WEB-INF/lib on Tomcat 5?

后端 未结 7 799
终归单人心
终归单人心 2020-12-10 05:48

I have a legacy web app running in Tomcat 5.0.

This web app has two jars in WEB-INF/lib, let\'s say Foo-2.0.jar and Bar-2.0.jar

相关标签:
7条回答
  • 2020-12-10 06:51

    Tomcat 5's classloading precedence for webapps is roughly as follows: first the bootstrap/system (JRE/lib, then Tomcat's internal classes), then the webapp libraries (first WEB-INF/classes, then WEB-INF/lib), then the common libraries (first Tomcat/common, then Tomcat/lib) and finally the webapp-shared libraries (Tomcat/shared).

    So to get Foo-2.0.jar loaded before Bar-2.0.jar, best what you can do is to move Bar-2.0.jar from WEB-INF/lib to Tomcat/common or Tomcat/shared.

    The JAR's aren't loaded in alphabetic order of their name. At least, there's no spec which says that. Renaming them to change the alphabetical filename order makes no sense.

    0 讨论(0)
提交回复
热议问题