I have a JSF 2.0 Web Application with MyFaces implementation. The application runs on Apache Tomcat 7. When I do any modification on xhtml pages while I am running or debugging the application no changes reflect to the page. I need to restart tomcat in order to test even minor xhtml modifications. This causes loose of time during development.
I guess this is a MyFaces problem, because the problem started when I switched standard JSF implementation from Mojarra to MyFaces. How can this problem be solved?
MyFaces uses different Facelet caching algorithms than Mojarra and does it more agressively. You need to set the javax.faces.PROJECT_STAGE context parameter in web.xml to Development to tone it down.
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
Update: since Mojarra 2.2.11, it will behave the same. So, also on Mojarra, you'd need to set Development stage to turn off Facelet caching. Alternatively, explicitly set the javax.faces.FACELETS_REFRESH_PERIOD context parameter to 0.
<context-param>
<param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
<param-value>0</param-value>
</context-param>
A value of 0 means "never cache". Any negative value such as -1 means "cache infinitely". Any positive value such as 10 represents the amount of seconds to cache.
Don't forget to re-enable caching for production. The project stage is more useful as it can also be set via JNDI instead of via web.xml.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With