tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: Bug found when calling init methods of defined web apps
Date Thu, 27 Jul 2000 21:50:19 GMT
Dan Martens wrote:

> Hello all.
> This is my first message to this group so please let me know if you have
> heard of this behaviour before.  There is a bug in
> org.apache.tomcat.core.ContextManager which allows for the loading of every
> defined servlet in the web.xml file four times at startup.

If you are talking about the "conf/web.xml" file, and you have four web
apps in your
"webapps" directory, what you are seeing is actually the correct
behavior.  To understand
why, consider the following points:

* The "conf/web.xml" file in Tomcat 3.1 contains defaults that are
  common to all web applications.  When a context is started up,
  this file is read and processed before the "WEB-INF/web.xml" file
  for your own application is processed.  You can pretend that there
  is an invisible "include" for this file at the top of your
  web.xml file, if that makes things clearer.

* By the rules of the servlet specification, every single <servlet>
  definition that is processed from a "web.xml" file must cause the
  creation of a separate servlet instance (of the appropriate class).
  This would be true even if you had two <servlet> instances that
  named the same Java class file.  The reason you want this is that
  you may well have the same servlet class, under two different
  mappings, with two different sets of initialization parameters.

* Because the "conf/web.xml" file contains commonly used servlets
  (like the JSP page compiler servlet), an instance of that servlet
  gets created for each web application.

* This is a "good thing", because each web application has its own
  custom class path (to access the WEB-INF/classes and WEB-INF/lib
  directories of each application).  If Tomcat were changed in the way
  that you are describing, the JSP page compiler for all four web apps
  would reference only the classes from the web app that was initialized

Craig McClanahan

View raw message