As taken from FacesServlet
documentation:
This servlet must automatically be mapped if it is not explicitly mapped in web.xml or web-fragment.xml and one or more of the following conditions are true.
A faces-config.xml file is found in WEB-INF.
A faces-config.xml file is found in the META-INF directory of a jar in the application's classpath.
A filename ending in .faces-config.xml is found in the META-INF directory of a jar in the application's classpath.
The javax.faces.CONFIG_FILES context param is declared in web.xml or web-fragment.xml.
The Set of classes passed to the onStartup() method of the ServletContainerInitializer implementation is not empty.
You can put your configuration file elsewhere in your webapp, but you need to keep in mind the following facts:
- You don't want to expose the file to be accessible, thus you'd want it to end up under
WEB-INF
/META-INF
folders; You need to add the following entry to your web.xml:
<context-param> <param-name>javax.faces.CONFIG_FILES</param-name> <param-value> WEB-INF/path/to/faces-config.xml </param-value> </context-param>
Otherwise the faces-config.xml is loaded automatically if found in some predefined locations.