Question about undeploying application

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Question about undeploying application

Ivan Mladenović
Hello,

I’m using Tomcat 6.0.29. Tomcat manager application is enabled. Version of
installed Java is 1.6 update 18. Operating systems used to test this are
Windows 7 and Ubuntu 9.1.

There is one Spring web application that is deployed on Tomcat.  Deployed
application have some threads that are running in background.

Then try to un-deploy application by using Tomcat Manager. Application WAR
file and folder where WAR file is unpacked are removed, but I get this error
in logs:

*Aug 12, 2010 2:35:23 PM org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named
[scheduler_Worker-6] but has failed to stop it. This is very likely to
create a memory leak.*

When I try to deploy new version of application (also by using Tomcat
Manager)  I get the “Out of memory” exception.

I try to change definition of following listener:

*<Listener
className="org.apache.catalina.core.JreMemoryLeakPreventionListener"
gcDaemonProtection="false" />*

And I also try to add following parameters in context.xml:
*
<Context antiJARLocking="true" antiResourceLocking="true">
*
Can I configure Tomcat to kill all treads when application is undeployed?

Thanks in advance.

Ivan
Reply | Threaded
Open this post in threaded view
|

RE: Question about undeploying application

Caldarale, Charles R
> From: Ivan Mladenović [mailto:[hidden email]]
> Subject: Question about undeploying application
>
> Deployed application have some threads that are running
> in background.

Then deployed application must stop those threads as part of its shutdown procedure.  Tomcat can't do it for you.  You should be using a ServletContextListener in your webapp, so it can properly manage the threads when its contextDestroyed() method is invoked.

> Can I configure Tomcat to kill all treads when application
> is undeployed?

No, that's the webapp's job.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Question about undeploying application

Ivan Mladenović
Hi,



Thanks for the quick answer.



I try this, but something strange is happening when I try to deploy
application (without the Tomcat restart).



I define ServletContextListener (create my implementation of this listener
and define this listener in web.xml). In method contextDestroyed I try to
shutdown all of the schedulers in following way:


ApplicationContext context = (ApplicationContext)
sce.getServletContext().getAttribute(WebApplicationContext.*
ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE*);



scheduler = (StdScheduler) context.getBean("scheduler");

cbcInterfaceScheduler.shutdown(*true*);



Boolean parameter means: wait for jobs to complete.



I follow the logs, destroy method is called and all schedulers are shutdown.

When I try to deploy same WAR file again, following error appears in
catalina log file:



Aug 13, 2010 12:22:54 PM org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads

SEVERE: The web application [] appears to have started a thread named
[scheduler_Worker-8] but has failed to stop it. This is very likely to
create a memory leak.

Aug 13, 2010 12:22:54 PM org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads

SEVERE: The web application [] appears to have started a thread named
[Thread-32] but has failed to stop it. This is very likely to create a
memory leak.



I also try to pause all jobs for scheduler and remove all jobs from
scheduler before I shutdown the scheduler, but I get the same error.



This is confusing for me because this is shown in log file when I try to
deploy application.



Could you give me some advice of how I can solve this?



Thanks in advance.





2010/8/12 Caldarale, Charles R <[hidden email]>

> > From: Ivan Mladenović [mailto:[hidden email]]
> > Subject: Question about undeploying application
> >
> > Deployed application have some threads that are running
> > in background.
>
> Then deployed application must stop those threads as part of its shutdown
> procedure.  Tomcat can't do it for you.  You should be using a
> ServletContextListener in your webapp, so it can properly manage the threads
> when its contextDestroyed() method is invoked.
>
> > Can I configure Tomcat to kill all treads when application
> > is undeployed?
>
> No, that's the webapp's job.
>
>  - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you received
> this in error, please contact the sender and delete the e-mail and its
> attachments from all computers.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Question about undeploying application

Christopher Schultz-2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ivan,

On 8/13/2010 6:45 AM, Ivan Mladenović wrote:
> I define ServletContextListener (create my implementation of this listener
> and define this listener in web.xml). In method contextDestroyed I try to
> shutdown all of the schedulers in following way:
>
> ApplicationContext context = (ApplicationContext)
> sce.getServletContext().getAttribute(WebApplicationContext.*
> ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE*);

I don't recognize the above, but I suppose you know what you are doing.

> scheduler = (StdScheduler) context.getBean("scheduler");
>
> cbcInterfaceScheduler.shutdown(*true*);

Are these the same object? It looks like you are not shutting-down the
object you got from the context.

> Boolean parameter means: wait for jobs to complete.
>
> I follow the logs, destroy method is called and all schedulers are shutdown.

Sounds good.

> When I try to deploy same WAR file again, following error appears in
> catalina log file:
>
> Aug 13, 2010 12:22:54 PM org.apache.catalina.loader.WebappClassLoader
> clearReferencesThreads
>
> SEVERE: The web application [] appears to have started a thread named
> [scheduler_Worker-8] but has failed to stop it. This is very likely to
> create a memory leak.

Could that be the old version of the webapp? Try a completely clean
deployment, then re-deploy and see what happens.

> Aug 13, 2010 12:22:54 PM org.apache.catalina.loader.WebappClassLoader
> clearReferencesThreads
>
> SEVERE: The web application [] appears to have started a thread named
> [Thread-32] but has failed to stop it. This is very likely to create a
> memory leak.

This is likely to be some /other/ thread - not scheduling related - that
your webapp created (note that it has a generic name).

> This is confusing for me because this is shown in log file when I try to
> deploy application.

Maybe ask the people who wrote the scheduler?

You may have to attach a profiler to the server and observe where these
threads are actually being created, and what actually happens when you
call the shutdown() method on your scheduler.

Hope that helps,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkxlm9kACgkQ9CaO5/Lv0PD31gCdGjtqde4FC7a3SWbsDWiggGpo
SLEAn1EwbJlLaTS17VIVmourUd35/QUJ
=bgTF
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Question about undeploying application

Ivan Mladenović
Hello,

Problem solved by changing Quartz scheduler version to 1.8.3.

Thanks for the help.



On Fri, Aug 13, 2010 at 9:24 PM, Christopher Schultz <
[hidden email]> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Ivan,
>
> On 8/13/2010 6:45 AM, Ivan Mladenović wrote:
> > I define ServletContextListener (create my implementation of this
> listener
> > and define this listener in web.xml). In method contextDestroyed I try to
> > shutdown all of the schedulers in following way:
> >
> > ApplicationContext context = (ApplicationContext)
> > sce.getServletContext().getAttribute(WebApplicationContext.*
> > ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE*);
>
> I don't recognize the above, but I suppose you know what you are doing.
>
> > scheduler = (StdScheduler) context.getBean("scheduler");
> >
> > cbcInterfaceScheduler.shutdown(*true*);
>
> Are these the same object? It looks like you are not shutting-down the
> object you got from the context.
>
> > Boolean parameter means: wait for jobs to complete.
> >
> > I follow the logs, destroy method is called and all schedulers are
> shutdown.
>
> Sounds good.
>
> > When I try to deploy same WAR file again, following error appears in
> > catalina log file:
> >
> > Aug 13, 2010 12:22:54 PM org.apache.catalina.loader.WebappClassLoader
> > clearReferencesThreads
> >
> > SEVERE: The web application [] appears to have started a thread named
> > [scheduler_Worker-8] but has failed to stop it. This is very likely to
> > create a memory leak.
>
> Could that be the old version of the webapp? Try a completely clean
> deployment, then re-deploy and see what happens.
>
> > Aug 13, 2010 12:22:54 PM org.apache.catalina.loader.WebappClassLoader
> > clearReferencesThreads
> >
> > SEVERE: The web application [] appears to have started a thread named
> > [Thread-32] but has failed to stop it. This is very likely to create a
> > memory leak.
>
> This is likely to be some /other/ thread - not scheduling related - that
> your webapp created (note that it has a generic name).
>
> > This is confusing for me because this is shown in log file when I try to
> > deploy application.
>
> Maybe ask the people who wrote the scheduler?
>
> You may have to attach a profiler to the server and observe where these
> threads are actually being created, and what actually happens when you
> call the shutdown() method on your scheduler.
>
> Hope that helps,
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkxlm9kACgkQ9CaO5/Lv0PD31gCdGjtqde4FC7a3SWbsDWiggGpo
> SLEAn1EwbJlLaTS17VIVmourUd35/QUJ
> =bgTF
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>