Externalize JSF project stage
Java ServerFaces (JSF) has a configuration option that should be set to Development in development and Production in production:
<context-param> <param-name>javax.faces.PROJECT_STAGE</param-name> <param-value>Development</param-value> </context-param>
Unfortunately it is defined in web.xml, so the binary file installed in development must differ from the binary file in production. Find and replace at build time works, but it is cumbersome and prone to errors.
The ideal solution would be to use system properties, but JSF does not support that. However, JSF can use JNDI lookups! Why they would support something as complex as JNDI in place of something as simple and straightforward as system properties beats me, but there you are.
To use a JNDI lookup, add the following to web.xml instead of the context parameter:
<resource-ref> <res-ref-name>jsf/ProjectStage</res-ref-name> <res-type>java.lang.String</res-type> <lookup-name>JsfProjectStage</lookup-name> </resource-ref>
The lookup name can be defined in the application server. If it is missing JSF will warn, but defaults to production mode.