Your question is basically divided into 2 parts:
How to replace Tomcat's ROOT (root) application?
How do I remove the prefix faces
from my urls?
The first part is adapted from How to change the ROOT application? :
There are three methods (excluding):
First turn off your Tomcat server from the bin
folder ( sh shutdown.sh
or running shutdown.bat). Then, delete all the contents of the Tomcat webapps
folder ( rm -fr *
). Then, copy your WAR file into this folder and rename it to ROOT.war
, and finally start Tomcar again ( sh startup.sh
or running startup.bat
).
Leave your war file in $CATALINA_BASE/webapps
with its original name. Turn off the autoDeploy and deployOnStartup options on your server in the server.xml
file. Define a context ( <Context>
) in server.xml
explicitly, specify the attributes path
and docBase
. You must do this because you have disabled the Tomcat self-deployment mechanisms, and Tomcat will not deploy your applications anymore unless you find their contexts in server.xml
. You must restart Tomcat for the changes to take effect.
Place your WAR file outside of the $CATALINA_BASE/webapps
folder (it must be outside to prevent a double display). Place a context file called ROOT.xml
in $CATALINA_BASE/conf/
. The only element in this file MUST have a docBase attribute pointing to the location of your WAR file. The path
element must not be set (it is derived from the file name .xml
, in this case ROOT.xml
). See the documentation for the context container for more details.
Reference
In my opinion, I would choose the first alternative.
About the second part, check in your web.xml file how you have configured the urls mapping for FacesServlet
. I imagine you must have something like this:
<servlet-mapping>
<servlet-name>FacesServlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
There are many tutorials that do not explain this part well. The best thing is to change it to a more useful form:
<servlet-mapping>
<servlet-name>FacesServlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>