title: CSS and Javascript loads too long on Tomcat 8 or 9
body: <p>I have JSF application and it works fine when I run it on embedded Jetty server. However, when I deploy it to Tomcat 8.0.35 loading of the CSS and Javascript files takes more than 20 seconds. I have the same problem on the Tomcat running on Amazon AWS server and on the Tomcat running on local machine. These are all small files and none of them is loaded longer than 35ms on Jetty server.</p>
  
  <p>Tomcat logs do not indicate any kind of problems with the application, and this is happening on every page, even on the login page. </p>
  
  <p>The same problem I have with Tomcat 8 and Tomcat 9, but not with Tomcat 7. </p>
  
  <p>I would appreciate if somebody could give me idea what should I check or how to search for the source of the problem.</p>
  
  <p><strong>Edit:</strong>
   This is a h:head section of login page, but same problem is everywhere else:</p>
  
  <pre><code>&lt;h:head&gt;
  &lt;meta charset="utf-8" /&gt;
  &lt;meta http-equiv="X-UA-Compatible" content="IE=edge" /&gt;
  &lt;meta name="viewport" content="width=device-width, initial-scale=1" /&gt;
  &lt;script src="https://use.typekit.net/zvv0dgl.js"&gt;&lt;/script&gt;
  &lt;script&gt;try{Typekit.load({ async: true });}catch(e){}&lt;/script&gt;
  &lt;title&gt;ProSolo - Sign in&lt;/title&gt;
  &lt;link href="#{request.contextPath}/resources/css2/bootstrap.min.css" rel="stylesheet" /&gt;
  &lt;link href="#{request.contextPath}/resources/css2/awesome-bootstrap-checkbox.css" rel="stylesheet" /&gt;
  &lt;link href="#{request.contextPath}/resources/css2/style.css" rel="stylesheet" /&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>Edit 2 (web.xml):</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns="http://java.sun.com/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:web="http://java.sun.com/xml/ns/javaee"
       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"&gt;
      &lt;display-name&gt;ProSolo&lt;/display-name&gt;
      &lt;servlet&gt;
      &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.xhtml&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;servlet&gt;
      &lt;servlet-name&gt;fileServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.prosolo.services.upload.FileServlet&lt;/servlet-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;basePath&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/resources&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;fileServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/files/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;filter&gt;
      &lt;filter-name&gt;CharacterEncodingFilter&lt;/filter-name&gt;
      &lt;filter-class&gt;org.springframework.web.filter.CharacterEncodingFilter&lt;/filter-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;encoding&lt;/param-name&gt;
          &lt;param-value&gt;UTF-8&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;/filter&gt;
      &lt;filter-mapping&gt;
      &lt;filter-name&gt;CharacterEncodingFilter&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
      &lt;filter&gt;
      &lt;filter-name&gt;opensessioninview&lt;/filter-name&gt;
      &lt;filter-class&gt;org.prosolo.core.spring.OpenSessionInViewFilter&lt;/filter-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;singleSession&lt;/param-name&gt;
          &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;/filter&gt;
      &lt;filter-mapping&gt;
      &lt;filter-name&gt;opensessioninview&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
      &lt;filter&gt;
      &lt;filter-name&gt;Login Partial Response Redirect&lt;/filter-name&gt;
      &lt;filter-class&gt;org.prosolo.core.jsf.LoginPartialResponseRedirectFilter&lt;/filter-class&gt;
      &lt;/filter&gt;
      &lt;filter-mapping&gt;
      &lt;filter-name&gt;Login Partial Response Redirect&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
      &lt;filter&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
      &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt;
      &lt;/filter&gt;
      &lt;filter-mapping&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt;
      &lt;/filter-mapping&gt;
      &lt;!--  
      &lt;filter&gt;
        &lt;filter-name&gt;PrimeFaces FileUpload Filter&lt;/filter-name&gt;
        &lt;filter-class&gt;org.prosolo.core.jsf.primefaces.FileUploadFilter&lt;/filter-class&gt;
      &lt;/filter&gt;
      &lt;filter-mapping&gt;
        &lt;filter-name&gt;PrimeFaces FileUpload Filter&lt;/filter-name&gt;
        &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
      &lt;/filter-mapping&gt;
      --&gt;
      &lt;filter&gt;
      &lt;filter-name&gt;gzipResponseFilter&lt;/filter-name&gt;
      &lt;filter-class&gt;org.omnifaces.filter.GzipResponseFilter&lt;/filter-class&gt;
      &lt;/filter&gt;
      &lt;filter-mapping&gt;
      &lt;filter-name&gt;gzipResponseFilter&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt;
      &lt;dispatcher&gt;ERROR&lt;/dispatcher&gt;
      &lt;/filter-mapping&gt;
      &lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;
          org.prosolo.core.spring.SpringConfig,
          org.prosolo.core.spring.security.SpringSecurityConfig,
          org.prosolo.core.hibernate.HibernateConfig
      &lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
      &lt;param-name&gt;contextClass&lt;/param-name&gt;
      &lt;param-value&gt;org.springframework.web.context.support.AnnotationConfigWebApplicationContext&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
      &lt;param-name&gt;com.sun.faces.expressionFactory&lt;/param-name&gt;
      &lt;param-value&gt;com.sun.el.ExpressionFactoryImpl&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;!-- added for p:fileUpload, options: auto, native, commons--&gt;
      &lt;context-param&gt;
      &lt;param-name&gt;primefaces.UPLOADER&lt;/param-name&gt;
      &lt;param-value&gt;native&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;listener&gt;
      &lt;listener-class&gt;org.prosolo.app.BeforeContextLoader&lt;/listener-class&gt;
      &lt;/listener&gt;
      &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&gt;
      &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.request.RequestContextListener&lt;/listener-class&gt;
      &lt;/listener&gt;
      &lt;listener&gt;
      &lt;listener-class&gt;org.prosolo.app.AfterContextLoader&lt;/listener-class&gt;
      &lt;/listener&gt;
      &lt;listener&gt;
      &lt;listener-class&gt;org.apache.myfaces.webapp.StartupServletContextListener&lt;/listener-class&gt;
      &lt;/listener&gt;
      &lt;listener&gt;
      &lt;listener-class&gt;org.prosolo.web.SessionCountListener&lt;/listener-class&gt;
      &lt;/listener&gt;
      &lt;error-page&gt;
      &lt;exception-type&gt;javax.faces.application.ViewExpiredException&lt;/exception-type&gt;
      &lt;location&gt;/login.xhtml&lt;/location&gt;
      &lt;/error-page&gt;
      &lt;error-page&gt;
      &lt;exception-type&gt;java.lang.Throwable&lt;/exception-type&gt;
      &lt;location&gt;/login.xhtml&lt;/location&gt;
      &lt;/error-page&gt;
      &lt;session-config&gt;
      &lt;session-timeout&gt;10&lt;/session-timeout&gt;
      &lt;/session-config&gt;
      &lt;!-- In Production change javax.faces.FACELETS_REFRESH_PERIOD to -1 and javax.faces.PROJECT_STAGE to 'Production' --&gt;
      &lt;!-- In Development change javax.faces.FACELETS_REFRESH_PERIOD to 1 and javax.faces.PROJECT_STAGE to 'Development' --&gt;
      &lt;context-param&gt;
      &lt;param-name&gt;javax.faces.FACELETS_REFRESH_PERIOD&lt;/param-name&gt;
      &lt;param-value&gt;-1&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
      &lt;param-name&gt;javax.faces.PROJECT_STAGE&lt;/param-name&gt;
      &lt;param-value&gt;Production&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
      &lt;param-name&gt;com.sun.faces.enableRestoreView11Compatibility&lt;/param-name&gt;
      &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
      &lt;description&gt;State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2&lt;/description&gt;
      &lt;param-name&gt;javax.faces.STATE_SAVING_METHOD&lt;/param-name&gt;
      &lt;param-value&gt;server&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
      &lt;param-name&gt;javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE&lt;/param-name&gt;
      &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
      &lt;param-name&gt;javax.faces.FACELETS_LIBRARIES&lt;/param-name&gt;
      &lt;param-value&gt;/WEB-INF/functions.taglib.xml&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
      &lt;param-name&gt;org.apache.el.parser.SKIP_IDENTIFIER_CHECK&lt;/param-name&gt;
      &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
      &lt;param-name&gt;primefaces.THEME&lt;/param-name&gt;
      &lt;param-value&gt;none&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
      &lt;param-name&gt;primefaces.PUBLIC_CAPTCHA_KEY&lt;/param-name&gt;
      &lt;param-value&gt;***************************&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
      &lt;param-name&gt;primefaces.PRIVATE_CAPTCHA_KEY&lt;/param-name&gt;
      &lt;param-value&gt;********************************&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
      &lt;param-name&gt;org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION&lt;/param-name&gt;
      &lt;param-value&gt;20&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
      &lt;param-name&gt;org.apache.myfaces.SERIALIZE_STATE_IN_SESSION&lt;/param-name&gt;
      &lt;param-value&gt;false&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
      &lt;param-name&gt;org.apache.myfaces.COMPRESS_STATE_IN_SESSION&lt;/param-name&gt;
      &lt;param-value&gt;false&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
      &lt;param-name&gt;org.apache.myfaces.annotation.SCAN_PACKAGES&lt;/param-name&gt;
      &lt;param-value&gt;org.prosolo.web&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
      &lt;param-name&gt;org.apache.myfaces.STRICT_JSF_2_ALLOW_SLASH_LIBRARY_NAME&lt;/param-name&gt;
      &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
      &lt;param-name&gt;org.apache.myfaces.USE_ENCRYPTION&lt;/param-name&gt;
      &lt;param-value&gt;false&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
      &lt;param-name&gt;org.apache.myfaces.ALGORITHM&lt;/param-name&gt;
      &lt;param-value&gt;AES&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
      &lt;param-name&gt;org.apache.myfaces.SECRET&lt;/param-name&gt;
      &lt;param-value&gt;Q0hBTkdFIFNFQ1JFVCEhIQ==&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
      &lt;param-name&gt;org.apache.myfaces.MAC_SECRET&lt;/param-name&gt;
      &lt;param-value&gt;Q0hBTkdFIE1BQ1NFQ1JFVA==&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
      &lt;param-name&gt;javax.faces.RESOURCE_EXCLUDES&lt;/param-name&gt;
      &lt;param-value&gt;.class .jsp .jspx .properties .xhtml .xml&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
      &lt;param-name&gt;javax.faces.FACELETS_BUFFER_SIZE&lt;/param-name&gt;
      &lt;param-value&gt;165535&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;listener&gt;
      &lt;listener-class&gt;org.ocpsoft.rewrite.servlet.impl.RewriteServletRequestListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  
      &lt;listener&gt;
      &lt;listener-class&gt;org.ocpsoft.rewrite.servlet.impl.RewriteServletContextListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  
      &lt;filter&gt;
      &lt;filter-name&gt;OCPsoft Rewrite Filter&lt;/filter-name&gt;
      &lt;filter-class&gt;org.ocpsoft.rewrite.servlet.RewriteFilter&lt;/filter-class&gt;
      &lt;async-supported&gt;true&lt;/async-supported&gt;
      &lt;/filter&gt;
      &lt;filter-mapping&gt;
      &lt;filter-name&gt;OCPsoft Rewrite Filter&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;dispatcher&gt;FORWARD&lt;/dispatcher&gt;
      &lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt;
      &lt;dispatcher&gt;INCLUDE&lt;/dispatcher&gt;
      &lt;dispatcher&gt;ERROR&lt;/dispatcher&gt;
      &lt;/filter-mapping&gt;
      &lt;!-- &lt;filter&gt;
       &lt;filter-name&gt;Save Page Url In Session Filter&lt;/filter-name&gt;
       &lt;filter-class&gt;org.prosolo.core.jsf.SavePageUrlInSessionFilter&lt;/filter-class&gt;
     &lt;/filter&gt;
     &lt;filter-mapping&gt;
       &lt;filter-name&gt;Save Page Url In Session Filter&lt;/filter-name&gt;
       &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
       &lt;dispatcher&gt;FORWARD&lt;/dispatcher&gt;
       &lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt;
     &lt;/filter-mapping&gt; --&gt;
  &lt;/web-app&gt;
  </code></pre>