title: Make use of web fragments (Servlet API 3.0) in a huge project environment
body: <p>We recently migrated to Servlet API 3.0. Since we are developing a framework which sometimes needs a few changes in the <code>web.xml</code>, projects which are based on our framework need to update their <code>web.xml</code> whenever a change in the framework is made.</p>
  
  <p>Servlet API 3.0 introduces the new <em>Web Fragments</em>, which make this behaviour more loosely coupled and dynamic. I create a <code>web-fragment.xml</code> and move all our stuff from the web.xml in there. So the projects now have only to define the following <code>web.xml</code> and their own additional declarations.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app 
     version="3.0"
     metadata-complete="false"
     xmlns="http://java.sun.com/xml/ns/javaee"
     xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
          http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>We have to use <code>metadata-complete="false"</code> to enable the Fragment search in JARs (our framework has the <code>web-fragment.xml</code> in <code>META-INF/</code>.</p>
  
  <p>Since we have many dependencies to other frameworks and libraries (about 80-90) and the <code>metadata-complete="false"</code> also triggers searching for Annotations it takes up to unacceptable <strong>12 seconds</strong> to search through all libraries.</p>
  
  <p>The mechanism as it is works great and I like the fact that we are more decoupled from our framework, but the startup time is fatal! Also we have to increase the available memory for Tomcat from <code>-Xms256m -Xmx512m</code> to <code>-Xms512m -Xmx1024m</code> to get it started without getting a <code>java.lang.OutOfMemoryError: Java heap space</code> (caused by the inefficiently implemented annotation processor of the Tomcat (about 50.000 classes are cached)).</p>
  
  <hr>
  
  <p><em>I know that we can disable the annotation search within a library, but as we use mostly third-party which don't have the <code>metadata-complete="true"</code> flag, this also isn't an option.</em></p>
  
  <p><strong>Can we do anything to disable the search for annotations? Or can we force the Servlet Container to only search in declared libraries for the <code>web-fragment.xml</code>?</strong> </p>
  
  <p>I would really like to use the new web fragment feature, but with the increased startup time and memory this isn't possible.</p>