You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Sparecreative <zo...@sparecreative.com> on 2008/03/29 11:03:45 UTC
ServletContextListener Query
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-tp16368464p16368464.html
Sent from the Tomcat - User mailing list archive at Nabble.com.
Re: ServletContextListener Query
Posted by Sparecreative <zo...@sparecreative.com>.
Len, you are a genius (in my kitchen anyway). That's exactly the issue. I
just checked. I had it set to reload during development, but we don't need
it anymore.
Thanks again.
Z.
Len Popp wrote:
>
> The key is this line:
> INFO: Reloading this Context has started
> It looks like the webapp is started, and then *immediately* it's
> re-loaded & started again. Reloading happens automatically if the
> app's <Context> has the attribute reloadable=true and the app is
> modified. It could be that the timestamp on one of the app's files
> (.war, .jsp, etc.) is messed up, or the time is set wrong on the
> server.
> If you don't want automatic reloading to happen at all, remove
> reloadable=true from the <Context> element.
> --
> Len
>
>
--
View this message in context: http://www.nabble.com/ServletContextListener-Query-tp16368464p16401690.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: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: ServletContextListener Query
Posted by Len Popp <le...@gmail.com>.
The key is this line:
INFO: Reloading this Context has started
It looks like the webapp is started, and then *immediately* it's
re-loaded & started again. Reloading happens automatically if the
app's <Context> has the attribute reloadable=true and the app is
modified. It could be that the timestamp on one of the app's files
(.war, .jsp, etc.) is messed up, or the time is set wrong on the
server.
If you don't want automatic reloading to happen at all, remove
reloadable=true from the <Context> element.
--
Len
On Sat, Mar 29, 2008 at 10:30 PM, Sparecreative <zo...@sparecreative.com> wrote:
>
> 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-tp16368464p16377750.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: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
---------------------------------------------------------------------
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
Re: ServletContextListener Query
Posted by Sparecreative <zo...@sparecreative.com>.
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" <zo...@sparecreative.com>
> To: <us...@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: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: ServletContextListener Query
Posted by Martin Gainty <mg...@hotmail.com>.
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" <zo...@sparecreative.com>
To: <us...@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-tp16368464p16377750.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: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
---------------------------------------------------------------------
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
Re: ServletContextListener Query
Posted by Sparecreative <zo...@sparecreative.com>.
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-tp16368464p16377750.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: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org