Hierarchical application context in J2EE app
I have a J2EE application (ear) with a web module, several jar modules, and a sar module (service archive - maybe specific to JBoss?).
The sar module starts up a JBoss scheduled task, and has its own Spring xml config file to create its own application context.
Currently this is quite separate from the web application context, which is created when the DispatcherServlet starts up from its own Spring xml config files.
This works OK, but there is some duplication between the two application contexts, and in particular I have to duplicate some properties files for the two contexts, which is clearly a Bad Thing.
I would like to configure it so the web context is a child of the sar context (the sar module starts up first - I'm not aware that that is configurable).
How can I do that? How can I make the context created by the sar module available to the DispatcherServlet? (the only idea I had was to register it with JNDI, but I read in a thread that that's illegal).
And supposing I can get at it from the DispatcherServlet, how do I configure that to use it as a parent context?