[jax-rs-spec users] Fwd: Lifecycle management in Application subclasses

From: James Shaw <>
Date: Thu, 6 Dec 2012 11:29:35 +0000

I hope this is the correct place to raise this.

I was looking for an Application method I could override that would be
executed when the servlet container shuts down (I have some
ExecutorServices that need to be stopped)

I couldn't find such a method, so I've worked around the problem by
implementing my own ServletContextListener and exposing the
ExecutorServices through a static accessor. Something like this:

@ApplicationPath("/") public class MyApplication extends Application {
    public MyApplication() {

@WebListener public class LifecycleListener implements
ServletContextListener { ... }

Has adding an Application.shutdown() hook to JAX-RS been discussed
before? Is there another way I ought to be doing this?