Thanks Martin,

But I'm not sure how spring can be the issue as it hasn't yet been
initialized. It's listener gets called after the ServletContextListener is
initialized.

In my web xml I don't define the spring servlet. I just define the listener
as follows:

    <listener>
       
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

Also, I found that the spring IOC mechanism isn't available to the
ServletContextListener. I had to get around this by applying the following
line in the contextInitialized method:

        WebApplicationContext wac =
WebApplicationContextUtils.getRequiredWebApplicationContext(event.getServletContext());
 


My main issue is why the ServletContext is created and destroyed and then
recreated on startup?

I've coded a workaround, but it would be nice not to have to.

Z. 



mgainty wrote:
> 
> Hi Zoran-
> 
> Spring doc at
> http://www.jdocs.com/spring/1.2.8/org/springframework/web/context/ContextLoa
> derServlet.html
> says
> This is a bootstrap listener and you will need an appserver that can work
> specifically with Bootstrap listeners
> This servlet should have a lower load-on-startup value in web.xml than any
> servlets that access the root web application context.
> e.g. the configuration in your web.xml for ContextLoadListener should look
> something like
>  <servlet>
>   <servlet-name>context</servlet-name>
> 
> <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet
> -class>
>   <load-on-startup>1</load-on-startup>
>  </servlet>
> 
> shy away from these 2.3 Servlet listeners which do not understand
> load-on-startup parameter
>   a.. BEA WebLogic up to 8.1 SP2
>   b.. IBM WebSphere 5.x
>   c.. Oracle OC4J 9.0.3
> Anyone else?
> Martin-
> ----- Original Message -----
> From: "Sparecreative" <[EMAIL PROTECTED]>
> To: <users@tomcat.apache.org>
> Sent: Saturday, March 29, 2008 9:30 PM
> Subject: Re: ServletContextListener Query
> 
> 
>>
>> The original formatting was all screwed up. My apologies.
>>
>> I'm seeing an issue when using a ServletContextListener on Tomcat 6.0.13.
>> Tomcat is triggering the contextInitialized method at startup but then
>> shortly after fires off the contextDestroyed method, followed by the
>> contextInitialized again. Is this normal behaviour or have I screwed
>> something up the config?
>>
>> Here are the relevant bits of my logs :
>>
>> Mar 29, 2008 8:49:13 PM org.apache.catalina.core.StandardEngine start
>> INFO: Starting Servlet Engine: Apache Tomcat/6.0.13
>>  INFO [main] - Context initialised
>>  INFO [main] - Context initialised
>>  INFO [main] - Loading spring configuration stuff.
>>  INFO [main] - Loading spring configuration stuff.
>>
>> Mar 29, 2008 8:49:30 PM org.apache.catalina.startup.Catalina start
>> INFO: Server startup in 17122 ms
>>  INFO [http-8080-1] - Context destoyed and threads interupted
>>  INFO [http-8080-1] - Context destoyed and threads interupted
>>
>> Mar 29, 2008 8:49:30 PM org.apache.catalina.core.StandardContext reload
>> INFO: Reloading this Context has started
>>  INFO [http-8080-1] - Context initialised
>>  INFO [http-8080-1] - Context initialised
>>  INFO [http-8080-1] - Loading spring configuration stuff.
>>  INFO [http-8080-1] - Loading spring configuration stuff.
>>
> 
> 

-- 
View this message in context: 
http://www.nabble.com/ServletContextListener-Query-tp16368464p16388856.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
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