tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Garret Wilson <gar...@globalmentor.com>
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="www.example.com" appBase="/var/web/apps"
 unpackWARs="false" autoDeploy="false"
 xmlValidation="false" xmlNamespaceAware="false">

    <Alias>example.com</Alias>

    <Context path="" docBase="www.example.com.war">
        <Parameter name="dataDirectory" 
value="/var/web/data/www.example.com/"/>
    </Context>

</Host>

In www.example.com.war 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/www.example.com/".

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 
myServlet1.init()?
* Why is the init parameter "dataDirectory" only available in the first 
call to myServlet1.init()?

Thanks for any insight,

Garret

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message