Java Code Examples for org.apache.catalina.connector.Connector#setPort()

The following examples show how to use org.apache.catalina.connector.Connector#setPort() . 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: TomcatConfig.java    From enhanced-pet-clinic with Apache License 2.0 6 votes vote down vote up
private Connector createSslConnector() {
	Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
	Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
	try {
		connector.setScheme("https");
		connector.setSecure(true);
		connector.setPort(tlsPort);

		File keystore = getKeyStoreFile();
		File truststore = keystore;

		protocol.setSSLEnabled(true);
		protocol.setKeystoreFile(keystore.getAbsolutePath());
		protocol.setKeystorePass(sslKeystorePassword);
		protocol.setTruststoreFile(truststore.getAbsolutePath());
		protocol.setTruststorePass(sslKeystorePassword);
		protocol.setKeyAlias(sslKeystoreAlias);
		return connector;
	} catch (IOException ex) {
		throw new IllegalStateException(
				"can't access keystore: [" + "keystore" + "] or truststore: [" + "keystore" + "]", ex);
	}
}
 
Example 2
Source File: ConnectorConf.java    From nano-framework with Apache License 2.0 6 votes vote down vote up
public Connector init() {
    final Connector connector = new Connector(protocal);
    connector.setPort(port);
    connector.setAsyncTimeout(connectionTimeout);
    connector.setRedirectPort(redirectPort);
    connector.setAttribute("executor", executor);
    connector.setEnableLookups(enableLookups);
    connector.setAttribute("acceptCount", acceptCount);
    connector.setMaxPostSize(maxPostSize);
    connector.setAttribute("compression", compression);
    connector.setAttribute("disableUploadTimeout", disableUploadTimeout);
    connector.setAttribute("noCompressionUserAgents", noCompressionUserAgents);
    connector.setAttribute("acceptorThreadCount", acceptorThreadCount);
    connector.setAttribute("compressableMimeType", compressableMimeType);
    connector.setURIEncoding(URIEncoding);
    return connector;
}
 
Example 3
Source File: Tomcat.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Get the default http connector. You can set more
 * parameters - the port is already initialized.
 *
 * <p>
 * Alternatively, you can construct a Connector and set any params,
 * then call addConnector(Connector)
 *
 * @return A connector object that can be customized
 */
public Connector getConnector() {
    Service service = getService();
    if (service.findConnectors().length > 0) {
        return service.findConnectors()[0];
    }

    if (defaultConnectorCreated) {
        return null;
    }
    // The same as in standard Tomcat configuration.
    // This creates an APR HTTP connector if AprLifecycleListener has been
    // configured (created) and Tomcat Native library is available.
    // Otherwise it creates a NIO HTTP connector.
    Connector connector = new Connector("HTTP/1.1");
    connector.setPort(port);
    service.addConnector(connector);
    defaultConnectorCreated = true;
    return connector;
}
 
Example 4
Source File: MBeanFactory.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Create a new Connector
 *
 * @param parent MBean Name of the associated parent component
 * @param address The IP address on which to bind
 * @param port TCP port number to listen on
 * @param isAjp Create a AJP/1.3 Connector
 * @param isSSL Create a secure Connector
 *
 * @exception Exception if an MBean cannot be created or registered
 */
private String createConnector(String parent, String address, int port, boolean isAjp, boolean isSSL)
    throws Exception {
    // Set the protocol
    String protocol = isAjp ? "AJP/1.3" : "HTTP/1.1";
    Connector retobj = new Connector(protocol);
    if ((address!=null) && (address.length()>0)) {
        retobj.setProperty("address", address);
    }
    // Set port number
    retobj.setPort(port);
    // Set SSL
    retobj.setSecure(isSSL);
    retobj.setScheme(isSSL ? "https" : "http");
    // Add the new instance to its parent component
    // FIX ME - addConnector will fail
    ObjectName pname = new ObjectName(parent);
    Service service = getService(pname);
    service.addConnector(retobj);

    // Return the corresponding MBean name
    ObjectName coname = retobj.getObjectName();

    return coname.toString();
}
 
Example 5
Source File: HttpProxyContainer.java    From odo with Apache License 2.0 6 votes vote down vote up
private Connector createSslConnector() {
    Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
    Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
    final int httpsPort = Utils.getSystemPort(Constants.SYS_HTTPS_PORT);
    try {
        File keyStore = com.groupon.odo.proxylib.Utils.copyResourceToLocalFile("tomcat.ks", "tomcat.ks");
        connector.setScheme("https");
        connector.setSecure(true);
        connector.setPort(httpsPort);
        protocol.setSSLEnabled(true);
        protocol.setSslProtocol("TLS");
        protocol.setKeystoreFile(keyStore.getAbsolutePath());
        protocol.setKeystorePass("changeit");
        return connector;
    } catch (IOException ex) {
        throw new IllegalStateException("can't access keystore: [" + "keystore"
                                            + "] or truststore: [" + "keystore" + "]", ex);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 6
Source File: WebAnno.java    From webanno with Apache License 2.0 5 votes vote down vote up
@Bean
public TomcatServletWebServerFactory servletContainer()
{
    TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
    if (ajpPort > 0) {
        Connector ajpConnector = new Connector(PROTOCOL);
        ajpConnector.setPort(ajpPort);
        ajpConnector.setAttribute("secretRequired", ajpSecretRequired);
        ajpConnector.setAttribute("secret", ajpSecret);
        ajpConnector.setAttribute("address", ajpAddress);
        factory.addAdditionalTomcatConnectors(ajpConnector);
    }
    return factory;
}
 
Example 7
Source File: IdpTest.java    From cxf-fediz with Apache License 2.0 5 votes vote down vote up
private static Tomcat startServer(boolean idp, String port)
    throws ServletException, LifecycleException, IOException {
    Tomcat server = new Tomcat();
    server.setPort(0);
    String currentDir = new File(".").getCanonicalPath();
    String baseDir = currentDir + File.separator + "target";
    server.setBaseDir(baseDir);

    server.getHost().setAppBase("tomcat/idp/webapps");
    server.getHost().setAutoDeploy(true);
    server.getHost().setDeployOnStartup(true);

    Connector httpsConnector = new Connector();
    httpsConnector.setPort(Integer.parseInt(port));
    httpsConnector.setSecure(true);
    httpsConnector.setScheme("https");
    httpsConnector.setAttribute("keyAlias", "mytomidpkey");
    httpsConnector.setAttribute("keystorePass", "tompass");
    httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
    httpsConnector.setAttribute("truststorePass", "tompass");
    httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
    httpsConnector.setAttribute("clientAuth", "want");
    // httpsConnector.setAttribute("clientAuth", "false");
    httpsConnector.setAttribute("sslProtocol", "TLS");
    httpsConnector.setAttribute("SSLEnabled", true);

    server.getService().addConnector(httpsConnector);

    File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
    server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());

    File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
    server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());

    server.start();

    return server;
}
 
Example 8
Source File: TokenExpiryTest.java    From cxf-fediz with Apache License 2.0 5 votes vote down vote up
private static void initRp() {
    try {
        rpServer = new Tomcat();
        rpServer.setPort(0);
        String currentDir = new File(".").getCanonicalPath();
        rpServer.setBaseDir(currentDir + File.separator + "target");

        rpServer.getHost().setAppBase("tomcat/rp/webapps");
        rpServer.getHost().setAutoDeploy(true);
        rpServer.getHost().setDeployOnStartup(true);

        Connector httpsConnector = new Connector();
        httpsConnector.setPort(Integer.parseInt(rpHttpsPort));
        httpsConnector.setSecure(true);
        httpsConnector.setScheme("https");
        httpsConnector.setAttribute("keyAlias", "mytomidpkey");
        httpsConnector.setAttribute("keystorePass", "tompass");
        httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
        httpsConnector.setAttribute("truststorePass", "tompass");
        httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
        // httpsConnector.setAttribute("clientAuth", "false");
        httpsConnector.setAttribute("clientAuth", "want");
        httpsConnector.setAttribute("sslProtocol", "TLS");
        httpsConnector.setAttribute("SSLEnabled", true);

        rpServer.getService().addConnector(httpsConnector);

        rpServer.addWebapp("/fedizhelloworld", "cxfWebappExpiry");

        rpServer.start();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 9
Source File: Http2Https.java    From springBoot with MIT License 5 votes vote down vote up
@Bean
public TomcatServletWebServerFactory servletContainerFactory() {
    TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory() {
        @Override
        protected void postProcessContext(Context context) {
            //设置安全性约束
            SecurityConstraint securityConstraint = new SecurityConstraint();
            securityConstraint.setUserConstraint("CONFIDENTIAL");
            //设置约束条件
            SecurityCollection collection = new SecurityCollection();
            //拦截所有请求
            collection.addPattern("/*");
            securityConstraint.addCollection(collection);
            context.addConstraint(securityConstraint);
        }
    };
    Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
    //设置将分配给通过此连接器接收到的请求的方案
    connector.setScheme("http");

    //true: http使用http, https使用https;
    //false: http重定向到https;
    connector.setSecure(false);

    //设置监听请求的端口号,这个端口不能其他已经在使用的端口重复,否则会报错
    connector.setPort(httpPort);

    //重定向端口号(非SSL到SSL)
    connector.setRedirectPort(sslPort);

    tomcat.addAdditionalTomcatConnectors(connector);
    return tomcat;
}
 
Example 10
Source File: WebConfiguration.java    From Spring-Boot-2.0-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
public void configureConnector(Connector connector) {
    if (port != null)
        connector.setPort(port);
    if (secure != null)
        connector.setSecure(secure);
    if (scheme != null)
        connector.setScheme(scheme);
    if (ssl != null)
        connector.setProperty("SSLEnabled", ssl.toString());
    if (keystore != null && keystore.exists()) {
        connector.setProperty("keystoreFile", keystore.getAbsolutePath());
        connector.setProperty("keystorePassword", keystorePassword);
    }
}
 
Example 11
Source File: SystemConfiguration.java    From NFVO with Apache License 2.0 5 votes vote down vote up
private Connector initiateHttpConnector() {

    Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");

    connector.setScheme("http");
    connector.setPort(8080);
    if (https) {
      connector.setSecure(false);
      connector.setRedirectPort(8443);
    }
    return connector;
  }
 
Example 12
Source File: HttpsConfiguration.java    From spring-boot with Apache License 2.0 5 votes vote down vote up
public Connector createSslConnector() {

        Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
        Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();

        connector.setPort(properties.getPort());
        connector.setScheme("https");
        connector.setSecure(true);
        protocol.setSSLEnabled(true);
        protocol.setClientAuth("false");
        protocol.setSSLProtocol("TLSv1+TLSv1.1+TLSv1.2");
        protocol.setKeystoreFile(properties.getKeystoreFile());
        protocol.setKeystorePass(properties.getKeystorePassword());
        return connector;
    }
 
Example 13
Source File: TomcatWebSocketTestServer.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public void setup() {
	Connector connector = new Connector(Http11NioProtocol.class.getName());
	connector.setPort(0);

	File baseDir = createTempDir("tomcat");
	String baseDirPath = baseDir.getAbsolutePath();

	this.tomcatServer = new Tomcat();
	this.tomcatServer.setBaseDir(baseDirPath);
	this.tomcatServer.setPort(0);
	this.tomcatServer.getService().addConnector(connector);
	this.tomcatServer.setConnector(connector);
}
 
Example 14
Source File: TomcatConnectorBean.java    From amazon-echo-ha-bridge with Apache License 2.0 5 votes vote down vote up
private Connector createConnector(int portNumber) {
    Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
    Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
    connector.setScheme("http");
    connector.setPort(portNumber);
    return connector;
}
 
Example 15
Source File: CustomConfig.java    From spring-boot-tutorial with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
private Connector createTomcatConnector() {
    Connector connector = new
        Connector("org.apache.coyote.http11.Http11NioProtocol");
    connector.setScheme("http");
    connector.setPort(8000);
    connector.setSecure(false);
    connector.setRedirectPort(8443);
    return connector;
}
 
Example 16
Source File: AbstractOIDCTest.java    From cxf-fediz with Apache License 2.0 4 votes vote down vote up
private static Tomcat startServer(int port, String servletContextName, String fedizConfigPath)
        throws ServletException, LifecycleException, IOException {
    Tomcat server = new Tomcat();
    server.setPort(0);
    Path targetDir = Paths.get("target").toAbsolutePath();
    server.setBaseDir(targetDir.toString());

    server.getHost().setAutoDeploy(true);
    server.getHost().setDeployOnStartup(true);

    Connector httpsConnector = new Connector();
    httpsConnector.setPort(port);
    httpsConnector.setSecure(true);
    httpsConnector.setScheme("https");
    httpsConnector.setAttribute("sslProtocol", "TLS");
    httpsConnector.setAttribute("SSLEnabled", true);
    httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks");
    httpsConnector.setAttribute("keystorePass", "tompass");

    if (null == servletContextName) { // IDP
        server.getHost().setAppBase("tomcat/idp/webapps");

        httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks");
        httpsConnector.setAttribute("truststorePass", "tompass");
        httpsConnector.setAttribute("clientAuth", "want");

        Path stsWebapp = targetDir.resolve(server.getHost().getAppBase()).resolve("fediz-idp-sts");
        server.addWebapp("/fediz-idp-sts", stsWebapp.toString());

        Path idpWebapp = targetDir.resolve(server.getHost().getAppBase()).resolve("fediz-idp");
        server.addWebapp("/fediz-idp", idpWebapp.toString());
    } else { // RP
        server.getHost().setAppBase("tomcat/rp/webapps");

        httpsConnector.setAttribute("clientAuth", "false");

        Path rpWebapp = targetDir.resolve(server.getHost().getAppBase()).resolve(servletContextName);
        Context ctx = server.addWebapp(servletContextName, rpWebapp.toString());

        // Substitute the IDP port. Necessary if running the test in eclipse where port filtering doesn't seem
        // to work
        Path fedizConfig = targetDir.resolve("tomcat").resolve(fedizConfigPath);
        try (InputStream is = AbstractOIDCTest.class.getResourceAsStream('/' + fedizConfigPath)) {
            byte[] content = new byte[is.available()];
            is.read(content);
            Files.write(fedizConfig,
                new String(content).replace("${idp.https.port}", Integer.toString(IDP_HTTPS_PORT)).getBytes());
        }

        if (!fedizConfigPath.contains("spring")) {
            FederationAuthenticator fa = new FederationAuthenticator();
            fa.setConfigFile(fedizConfig.toString());
            ctx.getPipeline().addValve(fa);
        }

        // callback
        ctx = server.addContext("", null);
        final String callbackName = "callback";
        Tomcat.addServlet(ctx, callbackName, new CallbackServlet());
        ctx.addServletMappingDecoded(CALLBACK_CONTEXT, callbackName);
        final String logoutName = "logout";
        Tomcat.addServlet(ctx, logoutName, new LogoutServlet());
        ctx.addServletMappingDecoded(LOGOUT_CONTEXT, logoutName);
    }

    server.getService().addConnector(httpsConnector);

    server.start();

    return server;
}
 
Example 17
Source File: TomcatBaseTest.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Before
@Override
public void setUp() throws Exception {
    super.setUp();

    // Trigger loading of catalina.properties
    CatalinaProperties.getProperty("foo");

    File appBase = new File(getTemporaryDirectory(), "webapps");
    if (!appBase.exists() && !appBase.mkdir()) {
        fail("Unable to create appBase for test");
    }

    tomcat = new TomcatWithFastSessionIDs();

    String protocol = getProtocol();
    Connector connector = new Connector(protocol);
    // Listen only on localhost
    connector.setAttribute("address",
            InetAddress.getByName("localhost").getHostAddress());
    // Use random free port
    connector.setPort(0);
    // Mainly set to reduce timeouts during async tests
    connector.setAttribute("connectionTimeout", "3000");
    tomcat.getService().addConnector(connector);
    tomcat.setConnector(connector);

    // Add AprLifecycleListener if we are using the Apr connector
    if (protocol.contains("Apr")) {
        StandardServer server = (StandardServer) tomcat.getServer();
        AprLifecycleListener listener = new AprLifecycleListener();
        listener.setSSLRandomSeed("/dev/urandom");
        server.addLifecycleListener(listener);
        connector.setAttribute("pollerThreadCount", Integer.valueOf(1));
    }

    File catalinaBase = getTemporaryDirectory();
    tomcat.setBaseDir(catalinaBase.getAbsolutePath());
    tomcat.getHost().setAppBase(appBase.getAbsolutePath());

    accessLogEnabled = Boolean.parseBoolean(
        System.getProperty("tomcat.test.accesslog", "false"));
    if (accessLogEnabled) {
        String accessLogDirectory = System
                .getProperty("tomcat.test.reports");
        if (accessLogDirectory == null) {
            accessLogDirectory = new File(getBuildDirectory(), "logs")
                    .toString();
        }
        AccessLogValve alv = new AccessLogValve();
        alv.setDirectory(accessLogDirectory);
        alv.setPattern("%h %l %u %t \"%r\" %s %b %I %D");
        tomcat.getHost().getPipeline().addValve(alv);
    }

    // Cannot delete the whole tempDir, because logs are there,
    // but delete known subdirectories of it.
    addDeleteOnTearDown(new File(catalinaBase, "webapps"));
    addDeleteOnTearDown(new File(catalinaBase, "work"));
}
 
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: TomcatServer.java    From onetwo with Apache License 2.0 4 votes vote down vote up
protected void addSSLConnector(){
	Connector connector = new Connector("HTTP/1.1");
       // connector = new Connector("org.apache.coyote.http11.Http11Protocol"); 
       connector.setPort(8443);
}
 
Example 20
Source File: TomcatBaseTest.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@Before
@Override
public void setUp() throws Exception {
    super.setUp();

    // Trigger loading of catalina.properties
    CatalinaProperties.getProperty("foo");

    File appBase = new File(getTemporaryDirectory(), "webapps");
    if (!appBase.exists() && !appBase.mkdir()) {
        Assert.fail("Unable to create appBase for test");
    }

    tomcat = new TomcatWithFastSessionIDs();

    String protocol = getProtocol();
    Connector connector = new Connector(protocol);
    // Listen only on localhost
    connector.setAttribute("address",
            InetAddress.getByName("localhost").getHostAddress());
    // Use random free port
    connector.setPort(0);
    // Mainly set to reduce timeouts during async tests
    connector.setAttribute("connectionTimeout", "3000");
    tomcat.getService().addConnector(connector);
    tomcat.setConnector(connector);

    // Add AprLifecycleListener if we are using the Apr connector
    if (protocol.contains("Apr")) {
        StandardServer server = (StandardServer) tomcat.getServer();
        AprLifecycleListener listener = new AprLifecycleListener();
        listener.setSSLRandomSeed("/dev/urandom");
        server.addLifecycleListener(listener);
        connector.setAttribute("pollerThreadCount", Integer.valueOf(1));
    }

    File catalinaBase = getTemporaryDirectory();
    tomcat.setBaseDir(catalinaBase.getAbsolutePath());
    tomcat.getHost().setAppBase(appBase.getAbsolutePath());

    accessLogEnabled = Boolean.parseBoolean(
        System.getProperty("tomcat.test.accesslog", "false"));
    if (accessLogEnabled) {
        String accessLogDirectory = System
                .getProperty("tomcat.test.reports");
        if (accessLogDirectory == null) {
            accessLogDirectory = new File(getBuildDirectory(), "logs")
                    .toString();
        }
        AccessLogValve alv = new AccessLogValve();
        alv.setDirectory(accessLogDirectory);
        alv.setPattern("%h %l %u %t \"%r\" %s %b %I %D");
        tomcat.getHost().getPipeline().addValve(alv);
    }

    // Cannot delete the whole tempDir, because logs are there,
    // but delete known subdirectories of it.
    addDeleteOnTearDown(new File(catalinaBase, "webapps"));
    addDeleteOnTearDown(new File(catalinaBase, "work"));
}