You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by ji...@svensktnaringsliv.se on 2015/12/02 16:13:13 UTC

RE: Detect shutdown when in common/global classpath?

Mark wrote:
> On 30/11/2015 15:51, jimi.hullegard@svensktnaringsliv.se wrote:
> > Hi,
> > 
> > When running code in a webapp, I know it is possible to detect an undeploy of the webapp, or shutdown of Tomcat, using a ServletContextListener. But how about code running outside the webapp?
> > 
> > The background for this is that we have written a plugin to a CMS, and this plugin exists in the common/global classpath. The CMS calls the plugin on certain occasions, triggered by some custom scheduling logic, and if we are unlucky our plugin gets called during a shutdown of Tomcat giving us strange  errors that result in an unnecessary error report email being sent. So what I would like to do is to add some check in our plugin, to avoid doing anything if Tomcat is in the process of shutting down. But is this possible, without some ugly hack?
> 
> Use a LifecycleListener that notifies your plug-in when Tomcat is shutting down. See org.apache.catalina.startup.VersionLoggerListener for an example.

Thanks Mark, that was exactly what I was looking for!

/Jimi

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org