tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dan Martens" <>
Subject Re: Bug found when calling init methods of defined web apps
Date Thu, 27 Jul 2000 18:33:24 GMT
If you had read the rest of my post you would have noticed that I mentioned 
that each entry in the conf/web.xml file is being loaded four different 
times.  So essentially the same file is being parsed four different times.  
This cannot at all be the correct behaviour at all because this is causing 
four different instances of every single defined webapp in the file, all 
with the same mapping. If still do not know what I mean, create a simple 
testing servlet with a println statement in the init method.  Define this 
servlet in the conf/web.xml file with the a loadatstartup value of 1 or any 
other +ve integer.  Then run tomcat, and watch the standard out.  This 
should clarify my point.

>From: "Craig R. McClanahan" <>
>Subject: Re: Bug found when calling init methods of defined web apps
>Date: Thu, 27 Jul 2000 14:50:19 -0700
>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 
> > 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
>   first.
>Craig McClanahan
>To unsubscribe, e-mail:
>For additional commands, e-mail:

Get Your Private, Free E-mail from MSN Hotmail at

View raw message