javaeclipsemavenjsf-2.2faces-config

cvc-complex-type.2.4.a invalid content was found starting with element factory in faces-config.xml


I have this error in a eclipse project, imported from a Netbeans project, set as a maven and project facet to Dynamic Web Project ( CDI1.1, Java 1.8, JS 1.0, JSF 2.2, JAX-RS 2.0, JBoss Maven Integration 1.0 and JPA 2.1)

<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="2.2"
              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-facesconfig_2_2.xsd">

    <application>
        <locale-config>
            <default-locale>en</default-locale>
            <supported-locale>fr</supported-locale>
        </locale-config>
        <resource-bundle>
            <base-name>Messages</base-name>
            <var>messages</var>
        </resource-bundle>


         <factory>
            <exception-handler-factory>org.omnifaces.exceptionhandler.FullAjaxExceptionHandlerFactory</exception-handler-factory> 
        </factory>

    </application>
</faces-config>

Solution

  • The answer is in the question, no node factory is allowed under the node application according to the XSD file http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd such that your XML file is invalid.

    The list of supported elements under application is:

    According to the XSD file, The node factory seems to be expected at the same level as application so directly under faces-config as next:

    <faces-config ...
        <application>
        ...
        </application>
         <factory>
            <exception-handler-factory>org.omnifaces.exceptionhandler.FullAjaxExceptionHandlerFactory</exception-handler-factory> 
        </factory>
    </faces-config>