0

I'm using the OmniFaces ExtensionlessURL FacesViews feature in one of my projects and have found that this feature does not appear to work when the web application is packaged as skinny WAR archive inside an EAR archive and deployed to either a Wildfly container or a WebSphere Liberty Profile container. On both containers I get a 404 error if I try to access a page without the .xhtml suffix.

If I deploy the same EAR archive which contains a skinny WAR archive to a GlassFish container or a WebLogic container, then the ExtensionlessURL feature works as expected and the pages are accessible without the .xhtml suffix.

If I deploy an EAR archive which contains a normal WAR archive (i.e. the OmniFaces jar is stored in the WAR archive's WEB-INF/lib folder), then the ExtensionlessURL works as expected on a WildFly container and a WebSphere Liberty Profile container in addition to the GlassFish and WebLogic containers.

The version of WildFly I'm using is 9.0.2 and the version of WebSphere Liberty Profile is 8.5.5.7. The version of OmniFaces I'm using is 2.2

Is there something I can change within my configuration to allow the OmniFaces Extensionless URL feature to be used with skinny WAR archives on Wildfly and WebSphere Liberty profile containers or is this a bug?

To troubleshoot this issue I've created a self contained example which contains the bare minimum needed to reproduce the problem.

The web.xml file is as follows:

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    version="3.1">

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

    <servlet>
        <servlet-name>facesServlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
        <async-supported>true</async-supported>
    </servlet>
    <servlet-mapping>
        <servlet-name>facesServlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
        <welcome-file>index.xhtml</welcome-file>
    </welcome-file-list>

</web-app>

The configuration for the Maven WAR plugin is as follows:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.6</version>
    <configuration>
        <failOnMissingWebXml>false</failOnMissingWebXml>
        <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
        <archive>
            <manifest>
                <addClasspath>true</addClasspath>
                <classpathPrefix>lib/</classpathPrefix>
            </manifest>
        </archive>
    </configuration>
</plugin>

The configuration for the Maven EAR plugin is as follows:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-ear-plugin</artifactId>
    <version>2.10.1</version>
    <configuration>
        <version>7</version>
        <defaultLibBundleDir>lib</defaultLibBundleDir>
        <skinnyWars>true</skinnyWars>
        <modules>
            <webModule>
                <groupId>${project.groupId}</groupId>
                <artifactId>extensionless-web</artifactId>
                <context-root>/extensionless-web</context-root>
            </webModule>
        </modules>
    </configuration>
</plugin>

The Maven EAR project also contains the following dependency to pull in the dependencies from the WAR project:

<dependency>
    <groupId>${project.groupId}</groupId>
    <artifactId>extensionless-web</artifactId>
    <version>${project.version}</version>
    <type>pom</type>
</dependency>
Paul H
  • 2,104
  • 7
  • 39
  • 53
  • "skinny WAR" is fishy. Nonetheless, what is the OmniFaces version? Try a decent version. The latest one is 2.2. – Tiny Dec 14 '15 at 12:03
  • Good point - completely forgot to include the OmniFaces version. I'm running OmniFaces 2.2. – Paul H Dec 14 '15 at 12:05
  • Thanks BalusC, I've moved the OmniFaces jar back into the WEB-INF/lib folder and the ExtensionlessURL feature now works correctly on WildFly and WebSphere Liberty Profile as well as GlassFish and WebLogic. Unfortunately it seems that the Maven WAR plugin has an "all or nothing" approach to skinny WARs, so all the JAR files end up being moved to the EAR file. I can't see a way to keep some JARs in the WAR file's WEB-INF/lib folder and exclude them from the MANIFEST.MF file. – Paul H Dec 14 '15 at 13:36
  • Just put EAR libs in pom.xml of EAR itself. – BalusC Dec 14 '15 at 15:00
  • When using skinny wars, there is nothing that obligates you to move ALL jars out of your WAR. In actual fact, all TLD (tag library def) jars, web CDI jars such as org.springframework.web.context.ContextLoaderListener, etc... You can get a fairly extensive description of how to do skinny wars with maven looking at my blog article [Put your WARs on a diet with Maven: Maven and skinny wars!][1]. There are examples and a github sample project. [1]: https://mfjassociates.blogspot.com/2023/07/put-your-wars-on-diet-with-maven-maven.html – mario Jul 14 '23 at 12:55

0 Answers0