I recently started embedding Tomcat 7 for my integration tests, rather than Tomcat 6 as I need some of the 7 features and it’s our target container. Performance is very slow compared to Tomcat 6 embedded. It’s taking in the order of 20 seconds to start the server. This is the code I am using:
Tomcat tomcat = new Tomcat();
tomcat.setPort(port);
tomcat.setSilent(true);
tomcat.setBaseDir(".");
tomcat.getHost().setAppBase(webappDir);
tomcat.addWebapp(context, "");
tomcat.start();
Has anyone else experienced this or got suggestions for improving performance? I am running tests on Windows 7, Linux Mint and Ubuntu.
Perhaps it’s slow due to classpath scanning which is required for annotation-based configuration of Servlet 3.0. If you don’t need these features, try to add
metadata-complete="true"to yourweb.xml.