Take the 2-minute tour ×

Seems like the slow Tomcat 7 startup problem can be resolved with "metadata-complete" set to "true" in the web.xml, like so:

<web-app metadata-complete="true" id="WebApp_ID" version="3.0"...

The problem is that Tomcat scans for annotations at startup, and this significantly slows it down. My time is cut down from 25 secs to 5 secs. (More info here: Tomcat and Servlet 3.0 Web Configuration)

However, I have some annotations in my code, like:


I am confused - will my code work after I have set metadata-complete="true"? Do I have to remove annotations and move everything into web.xml?

share|improve this question
add comment

1 Answer

up vote 33 down vote accepted

The slow startup is caused because every single class file in every single JAR file in /WEB-INF/lib is also scanned for Servlet 3.0 specific annotations. You apparently have a lot of (large) JAR files in /WEB-INF/lib.

The metadata-complete="true" indicates that the JAR files in /WEB-INF/lib doesn't need to be scanned for Servlet 3.0 specific annotations, but the webapp's own classes will still be scanned.

Note that you listed there two JSF annotations and one Java SE annotation, not any Servlet 3.0 annotations. The Servlet 3.0 annotations are listed in the javax.servlet.annotation package. JSF will only scan for annotations when the JAR file contains a JSF 2.0 compatible /META-INF/faces-config.xml file. It won't immediately scan every single class in every JAR file. The Java SE @Override annotation is not a runtime annotation, but a compile-time aid only.

See also:

share|improve this answer
Very usefull answer, thanks! –  Danijel Mar 22 '12 at 10:52
You're welcome. –  BalusC Mar 22 '12 at 10:53
Thanks a lot – had missed the part that only JAR files are not scanned for annotations (till now thought that metadata-complete="true" affects web application's classes, too). –  Tomas R Nov 18 '12 at 18:51
This just reduced my startup by 50%, from ~110 to ~55. Why is it false by default? Are there any collateral effects I might be overlooking? @Danijel How did this work out for you? –  mattblang Apr 9 '13 at 16:05
@mattblang: JSF artifacts in (custom) tag/component libraries won't be auto-registered anymore. You'd need to explicitly register them yourselves where applicable. –  BalusC Apr 9 '13 at 16:06
show 8 more comments

Your Answer


