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 your web.xml
.
This is how it actually looks in web.xml header:
<?xml version="1.0" encoding="UTF-8"?>
<web-app metadata-complete="true" id="WebApp_ID" version="3.0"...
Some more info here: Tomcat and Servlet 3.0 Web Configuration
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With