@Override public synchronized void start() throws Exception { Host host = ServerUtil.getDefaultHost().getHost(); _serverContext = (StandardContext) host.findChild("/" + _contextName); if (_serverContext == null) { _serverContext = new StandardContext(); _serverContext.setPath("/" + _contextName); File docBase = new File(SERVER_TEMP_DIR, _contextName); if (!docBase.exists()) { if (!docBase.mkdirs()) { throw new RuntimeException("Unable to create temp directory " + docBase.getPath()); } } _serverContext.setDocBase(docBase.getPath()); _serverContext.addLifecycleListener(new ContextConfig()); final Loader loader = new WebCtxLoader(Thread.currentThread().getContextClassLoader()); loader.setContainer(host); _serverContext.setLoader(loader); _serverContext.setInstanceManager(new LocalInstanceManager()); Wrapper wrapper = _serverContext.createWrapper(); wrapper.setName(SERVLET_NAME); wrapper.setServletClass(SwitchYardRemotingServlet.class.getName()); wrapper.setLoadOnStartup(1); _serverContext.addChild(wrapper); _serverContext.addServletMapping("/*", SERVLET_NAME); host.addChild(_serverContext); _serverContext.create(); _serverContext.start(); SwitchYardRemotingServlet remotingServlet = (SwitchYardRemotingServlet) wrapper.getServlet(); remotingServlet.setEndpointPublisher(this); _log.info("Published Remote Service Endpoint " + _serverContext.getPath()); } else { throw new RuntimeException("Context " + _contextName + " already exists!"); } }