JSF 2.2 faces-config: Unknown Schema version: 2.2

放肆的年华 提交于 2019-11-29 01:08:11

The schema namespace for JSF 2.2 changed. The faces-config.xml has to look like this:

<faces-config 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"
    version="2.2">

</faces-config>

I had the same problem with eclipse. I still get a warning ("No grammar costraints..) But the application works. this is my faces-config file:

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


    <application>
            <action-listener>org.primefaces.application.DialogActionListener</action-    listener>
            <navigation-handler>org.primefaces.application.DialogNavigationHandler</navigation-handler>
            <view-handler>org.primefaces.application.DialogViewHandler</view-handler>

        <locale-config>
             <default-locale>de</default-locale>
             <supported-locale>en</supported-locale>
        </locale-config>

        <resource-bundle>
            <base-name>Messages</base-name>
            <var>msg</var>
        </resource-bundle>
    </application>

</faces-config>

Messages is the base file names for the properties.The files are called Messages.properties (default) and Messages_de.properties.

The reason of this problem is that http://java.sun.com/xml/ns/javaee/web-facesconfig_2_2.xsd address is invalid. Therefore, I can advise you to use following faces-config.xml file

<?xml version='1.0' encoding='UTF-8'?>

    <faces-config version="2.2"
        xmlns="http://java.sun.com/xml/ns/javaee" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/web-facesconfig_2_2.xsd">
       <application>

            <resource-library-contracts>
                <contract-mapping>
                    <url-pattern>/user/*</url-pattern>
                    <contracts>blue</contracts>
                </contract-mapping>
                <contract-mapping>
                    <url-pattern>*</url-pattern>
                    <contracts>red</contracts>
                </contract-mapping>
            </resource-library-contracts>
        </application>

    </faces-config>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!