The Tomcat app downloads all of its code from a can - where does it say to use this can?

This Java web application that I use to write other developers is structured in a standard way. However, the files are .classnot located under WEB-INF/classes, they are instead grouped together in .jar and saved in WEB-INF/lib/myapp.jar.

The problem is that I cannot find where the program tells Tomcat to load myapp.jarfor class files. The application is working fine, but how does it know to download this myapp.jar?

I tried to grepmake my way through almost all conf files (in Tomcat and inside the application), and nowhere can I link to this file myapp.jar.

+3
source share
3 answers

Following what @nhnb said, here's an explanation from Apache about how the Tomcat classLoader works.

WebappX . A class loader is created for each web application that is deployed in one Tomcat 6 example. All the unpacked classes and resources in the / WEB-INF / classes directory of your web application archive, plus the classes and resources in the JAR files in the / WEB-INF / lib directory of your archive web application directory, become visible to the containing web application, but without others.

So, if you want to reference myApp.jar, you must be under the same class loader of this webapp, which essentially means that you must be in the same webapp.

TOMCAT_HOME/lib (Tomcat 6 ) TOMCAT_HOME/common/lib. .

+4

Tomcat .jar WEB-INF/lib.

+3

This is actually the default behavior for the servlet container.

+2
source

Source: https://habr.com/ru/post/1775411/


All Articles