jsfurl-rewritingweb.xmltomcat8omnifaces

Extensionless URLs with OmniFaces FacesView does not work in 1.12


i am already using the nice omnifaces-lib (1.12) with some of its util-functions successfully. now i want to try its facesviews-feature for extensionless urls. after reading

http://showcase.omnifaces.org/facesviews/ExtensionlessURLs

and adding the magic line

<context-param>
  <param-name>org.omnifaces.FACES_VIEWS_SCAN_PATHS</param-name>
  <param-value>/*.xhtml</param-value>
</context-param>

to web.xml, it does not to seem have any effect. the server-console also does not tell anything about the new configuration.

calling http://localhost:8080/TestApp/test results in "requested resource is not available" while http://localhost:8080/TestApp/test.jsf works as expected. i also tried the examples from

http://omnifaces.org/docs/javadoc/2.2/org/omnifaces/facesviews/package-summary.html

is there any (configuration)-issue? thanks for any advice.

i am using mojarra 2.2.8 and omnifaces 1.12 and tomcat 8. i don't have any other jsf-libs such as primefaces or prettyfaces included.

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" version="3.1">
<display-name>Test</display-name>
<welcome-file-list>
    <welcome-file>index.xhtml</welcome-file>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
     <url-pattern>/javax.faces.resource/*</url-pattern>
     <url-pattern>*.jsf</url-pattern>
     <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
    <!-- param-value>Production</param-value -->
</context-param>
<context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>server</param-value>
</context-param>
<context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
</context-param>
<context-param>
    <param-name>javax.faces.FACELETS_DEVELOPMENT</param-name>
    <param-value>true</param-value>
</context-param>
<context-param>
    <param-name>org.omnifaces.FACES_VIEWS_SCAN_PATHS</param-name>
    <param-value>/*.xhtml</param-value>
</context-param>
<listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>


</web-app>

Solution

  • That was my mistake. The /META-INF/services/javax.servlet.ServletContainerInitializer file disappeared during the 1.10 split. That file contained an instruction to let the container execute the org.omnifaces.facesviews.FacesViewsInitializer class during startup, which in turn is responsible for scanning and registering extensionless files. It works fine in all 2.x versions and the last 1.x version where it worked is 1.8.3.

    It has been added back in this commit and a new 1.12.1 release has been baked. It's available here in Maven.