public void shutdownWeldIfRunning(boolean ignoreException) throws NamingException { if(weldStarter != null) { logger.trace("----> shutting down Weld"); if(ignoreException) { try { if (creationalContexts != null) { creationalContexts.close(); creationalContexts = null; } if (initialContext != null) { initialContext.close(); initialContext = null; } weldStarter.tearDown(); } catch (Throwable thw) { logger.debug("Ignored {}", thw); } } else { weldStarter.tearDown(); } weldStarter = null; } }