Everyone,

I found the answer to my second question, "Why isn't myServlet2.init() called before the second call to myServlet1.init()?" It turns out it was being called, but my debug trace statements had been redirected because my init() method had successfully redirected debug output.

So the sequence now looks like this:

1. myServlet1.init() is called. The init parameter "dataDirectory" is correctly set to "/var/web/data/www.example.com/", and debug output is successfully redirected.

2. myServlet2.init() is called. The init parameter "dataDirectory" is correctly set to "/var/web/data/www.example.com/", and debug output is still successfully redirected.

3. catalina.out indicates "Jun 25, 2006 4:23:40 PM org.apache.catalina.startup.HostConfig deployWAR" followed by "INFO: Deploying web application archive www.example.com.war

4. myServlet1.init() is called. The init parameter "dataDirectory" returns null, the static variable is no longer set, and output is no longer redirected.

5. myServlet2.init() is called. The init parameter "dataDirectory" returns null, the static variable is no longer set, and output is no longer redirected..

Note that in step 1 I set a static variable in my servlet that is verified in step 2. But by step 4 the static variable is gone!

Note that if I change unpackWARs="true", these errors still occur, even if I restart Tomcat after the WARs have been unpacked! (The only difference is that, in step 4, I have access to the real path of the WEB-INF directory.)

It's as if two instances of Tomcat are being run in two separate JVMS: one using the server.xml configuration, and another attempting to deploy the .war files using some default configuration. The first set of initialized servlets continue to run and accept connections. What's wrong here?

Thanks in advance,

Garret

Garret Wilson wrote:
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


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

Reply via email to