This question describes a nice way to have a shared Spring ApplicationContext as a parent to the ApplicationContexts several WAR within an EAR. (See also ContextLoader.loadParentContext.) This works fine but for the fact that ApplicationContext.close() is never called on this parent context when the server is shut down. This leads in our case to the server never shutting down, since the parent ApplicationContext contains a ThreadPool and starts ehcache, which also starts a couple of (non daemon) threads.
Has anybody an elegant idea how to close this shared ApplicationContext? You can of course put a ContextListener in one of the WARs and just call close() on the shared ApplicationContext, but ideally it should be automatically shut down only after all WAR ApplicationContext are closed.