We recently switched to Servlet API 3.0. Since we develop a structure that sometimes needs several changes in web.xml
, projects based on our structure should update their web.xml
whenever a structure change occurs.
Servlet API 3.0 introduces new web fragments that make this behavior more loosely coupled and dynamic. I create web-fragment.xml
and move all our materials from web.xml. Thus, now projects should only define the following web.xml
and their own additional ads.
<?xml version="1.0" encoding="UTF-8"?> <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"> </web-app>
We must use metadata-complete="false"
to enable fragment search in the JAR (our structure has web-fragment.xml
in META-INF/
.
Since we have a lot of dependencies on other frameworks and libraries (about 80-90), and metadata-complete="false"
also starts the search for annotations, it takes an invalid 12 seconds to search all libraries.
The mechanism, since it works great, and I like the fact that we are more separate from our structure, but the startup time is fatal! We also need to increase the available memory for Tomcat from -Xms256m -Xmx512m
to -Xms512m -Xmx1024m
to start it without receiving java.lang.OutOfMemoryError: Java heap space
(caused by an ineffective Tomcat annotation processor (about 50,000 classes are cached)).
I know that we can turn off the search for annotations in the library, but since we mainly use third-party ones that do not have the metadata-complete="true"
flag, this is also not an option.
Can we do anything to turn off annotation search? Or can we make the servlet container look only in the declared libraries for web-fragment.xml
?
I would really like to use the new web fragment feature, but with increased startup time and memory, this is not possible.