Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embedded Tomcat 7 slow compare to Tomcat 6

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.

like image 496
Paul Grenyer Avatar asked Jan 29 '12 16:01

Paul Grenyer


2 Answers

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.

like image 74
axtavt Avatar answered Nov 11 '22 05:11

axtavt


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

like image 24
Danijel Avatar answered Nov 11 '22 04:11

Danijel