icarus
icarus

Reputation: 161

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>

Upvotes: 1

Views: 2708

Answers (1)

Nicolas Filotto
Nicolas Filotto

Reputation: 45005

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:

  • action-listener
  • default-render-kit-id
  • message-bundle
  • navigation-handler
  • view-handler
  • state-manager
  • el-resolver
  • property-resolver
  • variable-resolver
  • resource-handler
  • resource-library-contracts
  • system-event-listener
  • locale-config
  • resource-bundle
  • application-extension
  • default-validators

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>

Upvotes: 2

Related Questions