users@glassfish.java.net

Re: Undeploy in GF

From: <glassfish_at_javadesktop.org>
Date: Thu, 15 Apr 2010 17:24:12 PDT

> Hi,
> I am facing the following issue: when I un-deploy the
> servlet, glassfish states that the servlet was
> successfully undeployed, but I can still see that it
> is running (it did not actually kill it). So my
> question is: Is there some kind of callback that I
> can subscribe in my app to see if app is being
> unloaded (and I will gracefully terminate threads and
> close connections). Alternatively, is there a way to
> just terminate all threads and close all connections
> upon unloading (some flag in configuration)?

Since the container doesn't create the threads and connections, it can't manage, and thus can not kill them automatically.

You can create a ServletContextListener for your web app. It has two methods: one that is called when you web app starts up and one when it is being stopped. These are excellent places to put this kind of startup and shutdown code for a web app.
[Message sent by forum member 'whartung']

http://forums.java.net/jive/thread.jspa?messageID=397264