It's caused because your <welcome-file>index.jon</welcome-file>
does not physically exist in the root folder. There's only an index.xhtml
. When a folder is being requested in the URL like /
, then the servletcontainer will first check if the physical file as specified in <welcome-file>
is present, so that it can decide whether to continue the request or return a 404. The servletcontainer does at that point not take the mappings of any registered servlets into account. In your particular case, index.jon
is a virtual URL and does not represent a physically existing file, hence the 404.
You can solve this by placing an empty but physically existing index.jon
file next to index.xhtml
file in the same folder. This way you fool the servletcontainer that the index.jon
really exists and then it will continue the request which will ultimately hit the FacesServlet
who serves the index.xhtml
.
An alternative is to change the FacesServlet
URL pattern of *.jon
to *.xhtml
so that you never need to fiddle with virtual URLs. If you really need it to be *.jon
for some unclear reason, then again another alternative is to rename the physical file from index.xhtml
to index.jon
and set javax.faces.DEFAULT_SUFFIX
context parameter to .jon
.
Note that the concrete problem is essentially unrelated to JSF. It's related to basic servlets. You'd have exactly the same problem when using a different kind of servlet.