Yoav & Jacob,

> >Are you sure about that?
> 
> Positive.  The example in SRV 10.2.2 makes this clear.  I've also
> inspected the code in tomcat and resin myself and they both implement
> the spec the same way.
> 
> >contextInitialized() get called when everything has gotten done
> >initializing.  That is, the webapp is now ready to run.  So, 
> in effect,
> a
> >servlet with <load-on-startup>1</load-on-startup> will get called
> *before*
> >the contextInitialized() method gets called because until 
> that servlet
> >completes the init(), the webapp is *not* initialized.
> 
> No.  Any servlet init() methods are called after contextInitialized().

I created a ServletContextListener that initializes log4j in
contextInitialized() and shuts it down in the contextDestroyed().  I also
have a basic servlet that calls log4j in the init() method (but does not do
any initialization).

I deploy these in resin 2.1.6 with the following web.xml snippet:

    <context-param>
        <param-name>trace-configuration-file</param-name>
        <param-value>WEB-INF/log4j-configuration.xml</param-value>
    </context-param>
    
    <listener>
        <listener-class>
 
com.bevocal.application.platform.trace.log4j.Log4jServletContextListener
        </listener-class>
    </listener>
    
    <!-- trace configuration servlet -->
    <servlet>
        <servlet-name>trace</servlet-name>
 
<servlet-class>com.bevocal.application.platform.trace.log4j.Log4jConfigServl
et</servlet-class>

        <load-on-startup>1</load-on-startup>
    </servlet>

The behavior I am seeing is the servlet init method appears to get called
(and I get a "log4j not initialized" error message) and THEN the
ServletContextListern contextInitialized() method gets called.  If I remove
the load-on-startup element, then I do not get the "log4j not initialized",
the contextInitialized() method is called, and when I access the servlet
then it's init method outputs a proper log message.

I don't know if this behavior is specific to resin or configurable within
resin, but not the behavior I am expecting given the previous discussion on
this thread.  So, did I miss something critical here?  It does not appear
that contextInitialized() is called before servlet init() methods if they
are configured to load on startup.  At least in resin.  Can someone try this
in Tomcat?

-Mark

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to