czwartek, 30 maja 2013

Web server slow start problem (Jetty/Tomcat)


Today I started to feel I am having a problem with my maven and Jetty configuration. It started slower and slower, without any clear reason. Simple web app consisting of just a 5 SOAP endpoints (CXF) started in about 1 minute.
So, I started to investigate it and found the reason - seems that the container was looking for Servlet 3.0 annotations in the whole classpath during the start. This was completely unnecessary in my case, since I am not using any of them.
To stop that - it is possible to inform the container in web.xml declaration, that our configuration is complete and there is no need to scan for it.

 <web-app xmlns="http://java.sun.com/xml/ns/javaee"
         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"
         metadata-complete="true"
         version="3.0">

After that, startup time went down to couple of seconds - voilà!

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

Brak komentarzy:

Prześlij komentarz