Java Code Examples for org.apache.catalina.Context#setLoader()

The following examples show how to use org.apache.catalina.Context#setLoader() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Starter.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
public void startPeopleService() throws Exception {
    final File base = createBaseDirectory();
    log.info("Using base folder: " + base.getAbsolutePath());

    final Tomcat tomcat = new Tomcat();
    tomcat.setPort(8080);
    tomcat.setBaseDir(base.getAbsolutePath());

    Context context = tomcat.addContext("/", base.getAbsolutePath());
    Tomcat.addServlet(context, "CXFServlet", new CXFServlet());

    context.addServletMapping("/rest/*", "CXFServlet");
    context.addApplicationListener(ContextLoaderListener.class.getName());
    context.setLoader(new WebappLoader(Thread.currentThread().getContextClassLoader()));

    context.addParameter("contextClass", AnnotationConfigWebApplicationContext.class.getName());
    context.addParameter("contextConfigLocation", AppConfig.class.getName());

    tomcat.start();
    tomcat.getServer().await();
}
 
Example 2
Source File: StrutsOneIT.java    From glowroot with Apache License 2.0 6 votes vote down vote up
@Override
public void executeApp() throws Exception {
    int port = getAvailablePort();
    Tomcat tomcat = new Tomcat();
    tomcat.setBaseDir("target/tomcat");
    tomcat.setPort(port);
    Context context =
            tomcat.addWebapp("", new File("src/test/resources/struts1").getAbsolutePath());

    WebappLoader webappLoader =
            new WebappLoader(ExecuteActionInTomcat.class.getClassLoader());
    context.setLoader(webappLoader);

    tomcat.start();

    AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
    int statusCode = asyncHttpClient.prepareGet("http://localhost:" + port + "/hello.do")
            .execute().get().getStatusCode();
    asyncHttpClient.close();
    if (statusCode != 200) {
        throw new IllegalStateException("Unexpected status code: " + statusCode);
    }

    tomcat.stop();
    tomcat.destroy();
}
 
Example 3
Source File: InvokeServletInTomcat.java    From glowroot with Apache License 2.0 6 votes vote down vote up
@Override
public void executeApp() throws Exception {
    int port = getAvailablePort();
    Tomcat tomcat = new Tomcat();
    tomcat.setBaseDir("target/tomcat");
    tomcat.setPort(port);
    Context context =
            tomcat.addWebapp(contextPath, new File("src/test/resources").getAbsolutePath());

    WebappLoader webappLoader =
            new WebappLoader(InvokeServletInTomcat.class.getClassLoader());
    context.setLoader(webappLoader);

    // this is needed in order for Tomcat to find annotated servlet
    VirtualDirContext resources = new VirtualDirContext();
    resources.setExtraResourcePaths("/WEB-INF/classes=target/test-classes");
    context.setResources(resources);

    tomcat.start();

    doTest(port);

    tomcat.stop();
    tomcat.destroy();
}
 
Example 4
Source File: GrailsIT.java    From glowroot with Apache License 2.0 6 votes vote down vote up
@Override
public void executeApp() throws Exception {
    int port = getAvailablePort();
    Tomcat tomcat = new Tomcat();
    tomcat.setBaseDir("target/tomcat");
    tomcat.setPort(port);
    Context context =
            tomcat.addWebapp("", new File("src/test/resources").getAbsolutePath());

    WebappLoader webappLoader = new WebappLoader(RenderInTomcat.class.getClassLoader());
    context.setLoader(webappLoader);

    // this is needed in order for Tomcat to find annotated classes
    VirtualDirContext resources = new VirtualDirContext();
    resources.setExtraResourcePaths("/WEB-INF/classes=target/test-classes");
    context.setResources(resources);

    tomcat.start();

    doTest(port);

    tomcat.stop();
    tomcat.destroy();
}
 
Example 5
Source File: JsfRenderIT.java    From glowroot with Apache License 2.0 6 votes vote down vote up
@Override
public void executeApp() throws Exception {
    int port = getAvailablePort();
    Tomcat tomcat = new Tomcat();
    tomcat.setBaseDir("target/tomcat");
    tomcat.setPort(port);
    Context context =
            tomcat.addWebapp("", new File("src/test/resources").getAbsolutePath());

    WebappLoader webappLoader = new WebappLoader(RenderJsfInTomcat.class.getClassLoader());
    context.setLoader(webappLoader);

    tomcat.start();

    doTest(port);

    tomcat.stop();
    tomcat.destroy();
}
 
Example 6
Source File: MeecrowaveRunMojo.java    From openwebbeans-meecrowave with Apache License 2.0 6 votes vote down vote up
private void reload(final Meecrowave meecrowave, final String context,
                    final Supplier<ClassLoader> loaderSupplier, final ClassLoader mojoLoader) {
    if (reloadGoals != null && !reloadGoals.isEmpty()) {
        final List<String> goals = session.getGoals();
        session.getRequest().setGoals(reloadGoals);
        try {
            lifecycleStarter.execute(session);
        } finally {
            session.getRequest().setGoals(goals);
        }
    }
    final Context ctx = Context.class.cast(meecrowave.getTomcat().getHost().findChild(context));
    if (useClasspathDeployment) {
        final Thread thread = Thread.currentThread();
        destroyTcclIfNeeded(thread, mojoLoader);
        thread.setContextClassLoader(loaderSupplier.get());
        ctx.setLoader(new ProvidedLoader(thread.getContextClassLoader(), meecrowave.getConfiguration().isTomcatWrapLoader()));
    }
    ctx.reload();
}
 
Example 7
Source File: Starter.java    From product-ei with Apache License 2.0 6 votes vote down vote up
public void startPeopleService() throws Exception {
    final File base = createBaseDirectory();
    log.info("Using base folder: " + base.getAbsolutePath());

    final Tomcat tomcat = new Tomcat();
    tomcat.setPort(8080);
    tomcat.setBaseDir(base.getAbsolutePath());

    Context context = tomcat.addContext("/", base.getAbsolutePath());
    Tomcat.addServlet(context, "CXFServlet", new CXFServlet());

    context.addServletMapping("/rest/*", "CXFServlet");
    context.addApplicationListener(ContextLoaderListener.class.getName());
    context.setLoader(new WebappLoader(Thread.currentThread().getContextClassLoader()));

    context.addParameter("contextClass", AnnotationConfigWebApplicationContext.class.getName());
    context.addParameter("contextConfigLocation", AppConfig.class.getName());

    tomcat.start();
    tomcat.getServer().await();
}
 
Example 8
Source File: InvokeJaxrsResourceInTomcat.java    From glowroot with Apache License 2.0 6 votes vote down vote up
public void executeApp(String webapp, String contextPath, String url) throws Exception {
    int port = getAvailablePort();
    Tomcat tomcat = new Tomcat();
    tomcat.setBaseDir("target/tomcat");
    tomcat.setPort(port);
    Context context = tomcat.addWebapp(contextPath,
            new File("src/test/resources/" + webapp).getAbsolutePath());

    WebappLoader webappLoader =
            new WebappLoader(InvokeJaxrsResourceInTomcat.class.getClassLoader());
    context.setLoader(webappLoader);

    tomcat.start();
    AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
    int statusCode = asyncHttpClient.prepareGet("http://localhost:" + port + contextPath + url)
            .execute().get().getStatusCode();
    asyncHttpClient.close();
    if (statusCode != 200) {
        throw new IllegalStateException("Unexpected status code: " + statusCode);
    }

    tomcat.stop();
    tomcat.destroy();
}
 
Example 9
Source File: InvokeJaxwsWebServiceInTomcat.java    From glowroot with Apache License 2.0 6 votes vote down vote up
public void executeApp(String webapp, String contextPath, String url) throws Exception {
    int port = getAvailablePort();
    Tomcat tomcat = new Tomcat();
    tomcat.setBaseDir("target/tomcat");
    tomcat.setPort(port);
    Context context = tomcat.addWebapp(contextPath,
            new File("src/test/resources/" + webapp).getAbsolutePath());

    WebappLoader webappLoader =
            new WebappLoader(InvokeJaxwsWebServiceInTomcat.class.getClassLoader());
    context.setLoader(webappLoader);

    tomcat.start();

    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setServiceClass(ForBothHelloAndRootService.class);
    factory.setAddress("http://localhost:" + port + contextPath + url);
    ForBothHelloAndRootService client = (ForBothHelloAndRootService) factory.create();
    client.echo("abc");

    checkForRequestThreads(webappLoader);
    tomcat.stop();
    tomcat.destroy();
}
 
Example 10
Source File: TestParallelWebappClassLoader.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Test
public void testParallelCapableOnJre7() {
    if (!JreCompat.isJre7Available()) {
        // ignore on Jre6 or lower
        return;
    }
    try {
        Tomcat tomcat = getTomcatInstance();
        Context ctx = tomcat.addContext("", null);

        WebappLoader webappLoader = new WebappLoader();
        webappLoader.setLoaderClass(PARALLEL_CLASSLOADER);
        ctx.setLoader(webappLoader);

        tomcat.start();

        ClassLoader classloader = ctx.getLoader().getClassLoader();

        Assert.assertTrue(classloader instanceof ParallelWebappClassLoader);

        // parallel class loading capable
        Method getClassLoadingLock =
                getDeclaredMethod(classloader.getClass(), "getClassLoadingLock", String.class);
        // make sure we have getClassLoadingLock on JRE7.
        Assert.assertNotNull(getClassLoadingLock);
        // give us permission to access protected method
        getClassLoadingLock.setAccessible(true);

        Object lock = getClassLoadingLock.invoke(classloader, DUMMY_SERVLET);
        // make sure it is not a ParallelWebappClassLoader object lock
        Assert.assertNotEquals(lock, classloader);
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("testParallelCapableOnJre7 fails.");
    }
}
 
Example 11
Source File: TestParallelWebappClassLoader.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Test
public void testParallelIncapableOnJre6() {
    if (JreCompat.isJre7Available()) {
        // ignore on Jre7 or above
        return;
    }
    try {
        Tomcat tomcat = getTomcatInstance();
        // Must have a real docBase - just use temp
        Context ctx = tomcat.addContext("",
                System.getProperty("java.io.tmpdir"));

        WebappLoader webappLoader = new WebappLoader();
        webappLoader.setLoaderClass(PARALLEL_CLASSLOADER);
        ctx.setLoader(webappLoader);

        tomcat.start();

        ClassLoader classloader = ctx.getLoader().getClassLoader();

        Assert.assertTrue(classloader instanceof ParallelWebappClassLoader);

        // parallel class loading capable
        Method getClassLoadingLock =
                getDeclaredMethod(classloader.getClass(), "getClassLoadingLock", String.class);
        // make sure we don't have getClassLoadingLock on JRE6.
        Assert.assertNull(getClassLoadingLock);
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("testParallelIncapableOnJre6 fails.");
    }
}
 
Example 12
Source File: TestStandardContext.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Test
public void testWebappLoaderStartFail() throws Exception {
    // Test that if WebappLoader start() fails and if the cause of
    // the failure is gone, the context can be started without
    // a need to redeploy it.

    // Set up a container
    Tomcat tomcat = getTomcatInstance();
    tomcat.start();
    // To not start Context automatically, as we have to configure it first
    ((ContainerBase) tomcat.getHost()).setStartChildren(false);

    FailingWebappLoader loader = new FailingWebappLoader();
    File root = new File("test/webapp-3.0");
    Context context = tomcat.addWebapp("", root.getAbsolutePath());
    context.setLoader(loader);

    try {
        context.start();
        fail();
    } catch (LifecycleException ex) {
        // As expected
    }
    assertEquals(LifecycleState.FAILED, context.getState());

    // The second attempt
    loader.setFail(false);
    context.start();
    assertEquals(LifecycleState.STARTED, context.getState());

    // Using a test from testBug49922() to check that the webapp is running
    ByteChunk result = getUrl("http://localhost:" + getPort() +
            "/bug49922/target");
    assertEquals("Target", result.toString());
}
 
Example 13
Source File: TestStandardContext.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Test
public void testWebappLoaderStartFail() throws Exception {
    // Test that if WebappLoader start() fails and if the cause of
    // the failure is gone, the context can be started without
    // a need to redeploy it.

    // Set up a container
    Tomcat tomcat = getTomcatInstance();
    tomcat.start();
    // To not start Context automatically, as we have to configure it first
    ((ContainerBase) tomcat.getHost()).setStartChildren(false);

    FailingWebappLoader loader = new FailingWebappLoader();
    File root = new File("test/webapp-3.0");
    Context context = tomcat.addWebapp("", root.getAbsolutePath());
    context.setLoader(loader);

    try {
        context.start();
        fail();
    } catch (LifecycleException ex) {
        // As expected
    }
    assertEquals(LifecycleState.FAILED, context.getState());

    // The second attempt
    loader.setFail(false);
    context.start();
    assertEquals(LifecycleState.STARTED, context.getState());

    // Using a test from testBug49922() to check that the webapp is running
    ByteChunk result = getUrl("http://localhost:" + getPort() +
            "/bug49922/target");
    assertEquals("Target", result.toString());
}
 
Example 14
Source File: InvokeSpringControllerInTomcat.java    From glowroot with Apache License 2.0 5 votes vote down vote up
public void executeApp(String webapp, String contextPath, RunnableWithPort runnable)
        throws Exception {
    int port = getAvailablePort();
    Tomcat tomcat = new Tomcat();
    tomcat.setBaseDir("target/tomcat");
    tomcat.setPort(port);
    Context context = tomcat.addWebapp(contextPath,
            new File("src/test/resources/" + webapp).getAbsolutePath());

    WebappLoader webappLoader =
            new WebappLoader(InvokeSpringControllerInTomcat.class.getClassLoader());
    context.setLoader(webappLoader);

    tomcat.start();

    runnable.run(port);

    // spring still does a bit of work after the response is concluded,
    // see org.springframework.web.servlet.FrameworkServlet.publishRequestHandledEvent(),
    // so give a bit of time here, otherwise end up with sporadic test failures due to
    // ERROR logged by org.apache.catalina.loader.WebappClassLoaderBase, e.g.
    // "The web application [] is still processing a request that has yet to finish"
    MILLISECONDS.sleep(200);
    checkForRequestThreads(webappLoader);
    tomcat.stop();
    tomcat.destroy();
}
 
Example 15
Source File: TestParallelWebappClassLoader.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Test
public void testParallelIncapableOnJre6() {
    if (JreCompat.isJre7Available()) {
        // ignore on Jre7 or above
        return;
    }
    try {
        Tomcat tomcat = getTomcatInstance();
        // Must have a real docBase - just use temp
        Context ctx = tomcat.addContext("",
                System.getProperty("java.io.tmpdir"));

        WebappLoader webappLoader = new WebappLoader();
        webappLoader.setLoaderClass(PARALLEL_CLASSLOADER);
        ctx.setLoader(webappLoader);

        tomcat.start();

        ClassLoader classloader = ctx.getLoader().getClassLoader();

        Assert.assertTrue(classloader instanceof ParallelWebappClassLoader);

        // parallel class loading capable
        Method getClassLoadingLock =
                getDeclaredMethod(classloader.getClass(), "getClassLoadingLock", String.class);
        // make sure we don't have getClassLoadingLock on JRE6.
        Assert.assertNull(getClassLoadingLock);
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("testParallelIncapableOnJre6 fails.");
    }
}
 
Example 16
Source File: TestParallelWebappClassLoader.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Test
public void testParallelCapableOnJre7() {
    if (!JreCompat.isJre7Available()) {
        // ignore on Jre6 or lower
        return;
    }
    try {
        Tomcat tomcat = getTomcatInstance();
        Context ctx = tomcat.addContext("", null);

        WebappLoader webappLoader = new WebappLoader();
        webappLoader.setLoaderClass(PARALLEL_CLASSLOADER);
        ctx.setLoader(webappLoader);

        tomcat.start();

        ClassLoader classloader = ctx.getLoader().getClassLoader();

        Assert.assertTrue(classloader instanceof ParallelWebappClassLoader);

        // parallel class loading capable
        Method getClassLoadingLock =
                getDeclaredMethod(classloader.getClass(), "getClassLoadingLock", String.class);
        // make sure we have getClassLoadingLock on JRE7.
        Assert.assertNotNull(getClassLoadingLock);
        // give us permission to access protected method
        getClassLoadingLock.setAccessible(true);

        Object lock = getClassLoadingLock.invoke(classloader, DUMMY_SERVLET);
        // make sure it is not a ParallelWebappClassLoader object lock
        Assert.assertNotEquals(lock, classloader);
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("testParallelCapableOnJre7 fails.");
    }
}
 
Example 17
Source File: StrutsTwoIT.java    From glowroot with Apache License 2.0 5 votes vote down vote up
@Override
public void executeApp() throws Exception {
    int port = getAvailablePort();
    Tomcat tomcat = new Tomcat();
    tomcat.setBaseDir("target/tomcat");
    tomcat.setPort(port);
    String subdir;
    try {
        Class.forName("org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter");
        subdir = "struts2.5";
    } catch (ClassNotFoundException e) {
        subdir = "struts2";
    }
    Context context = tomcat.addWebapp("",
            new File("src/test/resources/" + subdir).getAbsolutePath());

    WebappLoader webappLoader =
            new WebappLoader(ExecuteActionInTomcat.class.getClassLoader());
    context.setLoader(webappLoader);

    tomcat.start();

    AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
    int statusCode =
            asyncHttpClient.prepareGet("http://localhost:" + port + "/hello.action")
                    .execute().get().getStatusCode();
    asyncHttpClient.close();
    if (statusCode != 200) {
        throw new IllegalStateException("Unexpected status code: " + statusCode);
    }

    tomcat.stop();
    tomcat.destroy();
}
 
Example 18
Source File: TomcatServer.java    From athena-rest with Apache License 2.0 4 votes vote down vote up
private void initTomcat() {
	serverStatus = ServerStatus.STARTING;

	tomcat = new Tomcat();
	tomcat.setPort(port);

	// Changed it to use NIO due to poor performance in burdon test
	Connector connector = new Connector(Utils.getStringProperty(properties, "web.connectorProtocol"));

	
	connector.setURIEncoding("UTF-8");
	connector.setPort(port);
	connector.setUseBodyEncodingForURI(true);
	connector.setAsyncTimeout(Utils.getIntegerValue(properties,
			WEB_ASYNC_TIMEOUT, DEFAULT_ASYNC_TIMEOUT));
	connector.setAttribute("minProcessors", Utils.getIntegerValue(
			properties, WEB_MIN_PROCESSORS, DEFAULT_MIN_PROCESSORS));
	connector.setAttribute("maxProcessors", Utils.getIntegerValue(
			properties, WEB_MAX_PROCESSORS, DEFAULT_MAX_PROCESSORS));
	connector.setAttribute("acceptCount", Utils.getIntegerValue(properties,
			WEB_ACCEPT_COUNT, DEFAULT_ACCEPT_COUNT));
	connector.setAttribute("minSpareThreads", Utils.getIntegerValue(
			properties, WEB_MIN_SPARE_THREADS, DEFAULT_MIN_SPARE_THREADS));
	connector.setAttribute("maxThreads", Utils.getIntegerValue(properties,
			WEB_MAX_THREADS, DEFAULT_MAX_THREADS));
	connector.setRedirectPort(Utils.getIntegerValue(properties,
			WEB_REDIRECT_PORT, DEFAULT_WEB_REDIRECT_PORT));
	
	if (this.minThreads != -1 && this.maxThreads != -1) {
		connector.setAttribute("minThreads", minThreads);
		connector.setAttribute("maxThreads", maxThreads);
	}

	Service tomcatService = tomcat.getService();
	tomcatService.addConnector(connector);
	tomcat.setConnector(connector);

	Context context = null;
	try {
		context = tomcat.addWebapp(contextPath,
				new File(webappPath).getAbsolutePath());
	} catch (ServletException e) {
		log.error("Failed to add webapp + " + webappPath, e);

		exit();
	}
	context.setLoader(new WebappLoader(Thread.currentThread()
			.getContextClassLoader()));

	String extraResourcePaths = properties
			.getProperty(WEB_EXTRA_RESOURCE_PATHS);
	if (!StringUtils.isBlank(extraResourcePaths)) {
		VirtualDirContext virtualDirContext = new VirtualDirContext();
		virtualDirContext.setExtraResourcePaths(extraResourcePaths);
		context.setResources(virtualDirContext);
	}

	StandardServer server = (StandardServer) tomcat.getServer();
	AprLifecycleListener listener = new AprLifecycleListener();
	server.addLifecycleListener(listener);
}
 
Example 19
Source File: EmbeddedTomcatCustomizer.java    From pulsar-manager with Apache License 2.0 4 votes vote down vote up
@Bean
public ServletWebServerFactory servletContainer() {
    log.info("Starting servletContainer");
    return new TomcatServletWebServerFactory() {
        @Override
        protected TomcatWebServer getTomcatWebServer(Tomcat tomcat) {
            try {
                log.info("Catalina base is " + tomcat.getServer().getCatalinaBase().getAbsolutePath());
                File lib = new File("lib").getAbsoluteFile();
                if (lib.isDirectory()) {
                    File bkvmWar = searchWar(lib, "bkvm", ".war");
                    if (bkvmWar != null) {
                        File configFile = new File("bkvm.conf");
                        log.info("looking for BKVM configuration file at " + configFile.getAbsolutePath());
                        if (configFile.isFile()) {
                            Properties props = new Properties();
                            try (FileReader reader = new FileReader(configFile)) {
                                props.load(reader);
                            }
                            boolean bkvmEnabled = Boolean.parseBoolean(props.getProperty("bkvm.enabled", "false"));
                            log.info("Read bkvm.enabled = {}", bkvmEnabled);
                            if (bkvmEnabled) {
                                System.setProperty("bookkeeper.visual.manager.config.path", configFile.getAbsolutePath());
                                File file = new File(tomcat.getServer().getCatalinaBase(), "/webapps");
                                log.info("Tomcat Webapps directory is " + file.getAbsolutePath());
                                file.mkdirs();
                                File bkvmDirectory = new File(file, "bkvm");
                                log.info("Deploying BKVM to " + bkvmDirectory.getAbsolutePath());
                                unZip(bkvmWar, bkvmDirectory);
                                Context context = tomcat.addWebapp("/bkvm", bkvmDirectory.getAbsolutePath());
                                WebappLoader loader = new WebappLoader(Thread.currentThread().getContextClassLoader());
                                context.setLoader(loader);
                            }
                        }
                    }
                }
                return super.getTomcatWebServer(tomcat);
            } catch (IOException | ServletException ex) {
                throw new RuntimeException(ex);
            }
        }

    };
}
 
Example 20
Source File: JspRenderIT.java    From glowroot with Apache License 2.0 3 votes vote down vote up
@Override
public void executeApp() throws Exception {
    int port = getAvailablePort();
    Tomcat tomcat = new Tomcat();
    tomcat.setBaseDir("target/tomcat");
    tomcat.setPort(port);
    Context context =
            tomcat.addContext("", new File("src/test/resources").getAbsolutePath());

    WebappLoader webappLoader = new WebappLoader(RenderJspInTomcat.class.getClassLoader());
    context.setLoader(webappLoader);

    Tomcat.addServlet(context, "hello", new ForwardingServlet());
    context.addServletMapping("/hello", "hello");
    Tomcat.addServlet(context, "jsp", new JspServlet());
    context.addServletMapping("*.jsp", "jsp");

    tomcat.start();
    AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
    int statusCode = asyncHttpClient.prepareGet("http://localhost:" + port + "/hello")
            .execute().get().getStatusCode();
    asyncHttpClient.close();
    if (statusCode != 200) {
        throw new IllegalStateException("Unexpected status code: " + statusCode);
    }
    tomcat.stop();
    tomcat.destroy();
}