tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Garret Wilson <>
Subject Tomcat multiple init(), no init param
Date Sun, 25 Jun 2006 21:32:10 GMT
Tomcat 5.5.16 seems to call a servlet's init() method several times, and 
the specific init parameter is missing in all but the first.

I have a simple server.xml that includes:

<Host name="" appBase="/var/web/apps"
 unpackWARs="false" autoDeploy="false"
 xmlValidation="false" xmlNamespaceAware="false">


    <Context path="" docBase="">
        <Parameter name="dataDirectory" 


In I have a web.xml file that includes two instances 
of MyServlet, with servlet names of myServlet1 and myServlet2, mapped to 
"/*" and "/example/*", respectively.

Tomcat does the following, which I find odd:

1. myServlet1.init() is called. The init parameter "dataDirectory" is 
correctly set to "/var/web/data/".

2. catalina.out indicates "Jun 25, 2006 2:07:26 PM 
org.apache.catalina.startup.HostConfig deployWAR".

3. myServlet.init is called(). The init parameter "dataDirectory" 
returns null.

4. myServlet2.init is called(). The init parameter "dataDirectory" 
returns null.

(Then steps 3 and 4 are repeated, presumably because steps 2 and 3 throw 
NullPointerExceptions, which results from the missing init parameter.)

This confuses me:

* Why is myServlet1.init() called twice?
* Why isn't myServlet2.init() called before the second call to 
* Why is the init parameter "dataDirectory" only available in the first 
call to myServlet1.init()?

Thanks for any insight,


To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message