Experiences from Refactoring UI-Drive with Spring

20 May 2017


Tomcat cacheMaxSize

  1. When using Tomcat 8 with project containing many JARs (like Spring), we may see the warning logs:
     org.apache.catalina.webresources.Cache.getResource Unable to add the resource at [***] to the cache because there was insufficient free space available after evicting expired cache entries - consider increasing the maximum size of the cache
    

    This is commonly seen in Tomcat 8.

  2. Reason[1] is:
    • “Tomcat caches classes, JAR files, HTML, JSPs and any other files that contribute to the web application”
    • “The total cache size (cacheMaxSize) is 10240kb and de maximum object size (cacheObjectMaxSize) is 512kb” by default
  3. Solution[2] is (if you are using Eclipse):
    • in the Eclipse workspace, you should be able to find a Servers folder; find the Tomcat 8’s folder
    • inside it, find the context.xml file for Tomcat 8
    • add this before </context> tag
        <Resources cachingAllowed="true" cacheMaxSize="100000" />
      
    • restart Eclipse, hopefully you should find the problem solved

Other Notes

  1. To access form data (without binding with modelAttribute), @RequestParam(“userName”) String name

To be continued…

References

  1. Issue Discussion on Github
  2. StackOverflow Discussion
  3. Understanding Spring MVC Model and Session Attributes
  4. How do servlets work? Instantiation, sessions, shared variables and multithreading on Stack Overflow
  5. Spring MVC pass same object between controller
  6. GUI Architectures
comments powered by Disqus