if (ctx instanceof ApplicationContextFacade) {
try {
final ApplicationContext appCtx = (ApplicationContext) get(ApplicationContextFacade.class, ctx);
final Context tomcatCtx = (Context) get(ApplicationContext.class, appCtx);
if (!Arrays.asList(tomcatCtx.findApplicationListeners()).contains(StartupServletContextListener.class.getName())) {
addListener(ctx);
}
} catch (final Exception e) {
// add it, not important we'll simply get a warning saying it is already here
addListener(ctx);