Tomcat 7 startup time with metadata-complete

For anyone using Spring Framework with Tomcat 7, be sure to research the new annotation scanning (servlets-2.5) and web fragment (servlet-3.0) features of J2EE6. It’s enabled by default in Tomcat 7.   The result when using Spring’s annotations, is that the entire classpath gets scanned twice.   More information:

The J2EE scanning can be disabled by setting metadata-complete=”true” in web.xml.  This simple change  decreased my Tomcat 7 startup time on one medium size webapp by more than half. It’s likely even more significant on larger web apps, however, it did not seem to have as much affect on an older webapp I tested it with. I’m not exactly sure of the relevant combination of settings/libraries.

This setting is probably relevant to all servlet 2.5/3.0 compliant containers.  i.e.

 

This entry was posted in Technical. Bookmark the permalink.
  • Amit

    What does the servlet container do by scanning jar files for annotations and web-fragment.xml’s? If the application still works after adding metadata-complete=true, does it mean this tag just result in lazy class loading and initialization?