protected static WebAppContext findWAC(ServletContext context) {
if (context instanceof ContextHandler.Context) {
ContextHandler.Context sContext = (ContextHandler.Context) context;
ContextHandler contextHandler = sContext.getContextHandler();
Handler handler = contextHandler.getHandler();
if (handler instanceof ServletHandler) {
ServletHandler servletHandler = (ServletHandler) handler;
Server server = servletHandler.getServer();
Handler serverHandler = server.getHandler();
if (serverHandler instanceof HandlerCollection) {
HandlerCollection hc = (HandlerCollection) serverHandler;
for (Handler h : hc.getHandlers()) {
if (h instanceof WebAppContext) {
WebAppContext wac = (WebAppContext) h;