Java 将config-config.xml从1_2更新为2时出现问题

Java 将config-config.xml从1_2更新为2时出现问题,java,jsf,richfaces,faces-config,Java,Jsf,Richfaces,Faces Config,我在尝试配置JSF2时遇到问题 在本地启动Tomcat7服务器时,出现以下错误 SEVERE: Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! cvc-enumeration-valid:

我在尝试配置JSF2时遇到问题

在本地启动Tomcat7服务器时,出现以下错误

SEVERE: Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener
com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! cvc-enumeration-valid: Value '2.0' is not facet-valid with respect to enumeration '[1.2]'. It must be a value from the enumeration.
    at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:213)
    at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:196)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4521)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5004)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:4999)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)
Caused by: org.xml.sax.SAXParseException: cvc-enumeration-valid: Value '2.0' is not facet-valid with respect to enumeration '[1.2]'. It must be a value from the enumeration.
    at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.processOneAttribute(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.processAttributes(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
    at org.apache.xerces.jaxp.validation.DOMValidatorHelper.beginNode(Unknown Source)
    at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)
    at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)
    at org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown Source)
    at javax.xml.validation.Validator.validate(Validator.java:127)
    at com.sun.faces.config.ConfigManager$ParseTask.getDocument(ConfigManager.java:434)
    at com.sun.faces.config.ConfigManager$ParseTask.call(ConfigManager.java:394)
    at com.sun.faces.config.ConfigManager$ParseTask.call(ConfigManager.java:351)
    ... 5 more
在faces-config.xml中替换以下内容时发生错误:

<faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">

与:



在类路径中使用了JSF 1.2 libs而不是JSF 2.0 libs。删除/升级它们。

如何检查它们是什么版本的BalsusC?我可以在我的libs文件夹中看到jsf impl&jsfapi jar,但是上面没有版本名。您可以通过提取JAR并读取
MANIFEST.MF
文件来验证它。您也可以自己在下载并安装JSF2.x。这并不明显,堆栈跟踪没有说明JSF的版本,这个答案是正确的。在我的例子中,JSF LIB不仅像预期的那样在webapps libs dir中,而且在服务器公共libs dir中,出于某种原因,它尝试加载这些文件。我不知道为什么,我可以从那里删除它们。@Schlangi:异常消息“值'2.0'对于枚举'[1.2]'无效”非常明显。它说唯一有效的值是“1.2”,这反过来表明JSF1.2当前正在使用(在解析
值并根据模式验证它时抛出)。@BalusC:噢,你说得对。我的stack strace略有不同,没有包含版本信息。我在这里没有注意到,因为其余的异常看起来都一样(包括行号)。这可能是因为对我来说情况正好相反:我的应用程序非常旧,现在安装在更新的tomcat服务器上,所以tomcat预装了2版,我的应用程序需要1.2版
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
    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://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
    version="2.0">