Why doesn't Tomcat find classes in jars in the WEB-INF/lib directory?

Alessandro A. Garbagnati

According to the Servlet 2.2 specifications:

9.4: Directory Structure

A web application exists as a structured hierarchy of directories. The root of this hierarchy serves as a document root for serving files that are part of this context. For example, for a web application located at /catalog in a web server, the index.html file located at the base of the web application hierarchy can be served to satisfy a request to /catalog/index.html.

A special directory exists within the application hierarchy named “WEB-INF”. This directory contains all things related to the application that aren’t in the document root of the application. It is important to note that the WEB-INF node is not part of the public document tree of the application. No file contained in the WEB-INF directory may be served directly to a client.

The contents of the WEB-INF directory are:
  • /WEB-INF/web.xml deployment descriptor
  • /WEB-INF/classes/* directory for servlet and utility classes. The classes in this directory are used by the application class loader to load classes from.
  • - /WEB-INF/lib/*.jar area for Java ARchive files which contain servlets, beans, and other utility classes useful to the web application. All such archive files are used by the web application class loader to load classes from.
I've never had this problem with either Tomcat and Resin, unless the file was not a jar but a zip (It happened with Oracle's drivers that are packaged ina file called classes12.zip).
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact