无法在 JSF 应用程序中解析文档 faces-config.xml

Posted

技术标签:

【中文标题】无法在 JSF 应用程序中解析文档 faces-config.xml【英文标题】:Unable to parse document faces-config.xml in JSF application 【发布时间】:2016-06-11 19:55:32 【问题描述】:

我正在开发一个 JSF 网络应用程序。我将 JSF 2.2 与 Apache Tomcat 8.0.27.0 一起使用。 当我按下 clean & build 时,它工作正常,但是当我尝试运行我的应用程序时,我得到了这个异常:

     com.sun.faces.config.ConfigurationException: java.util.concurrent.ExecutionException: com.sun.faces.config.ConfigurationException: Unable to parse document 'file:/C:/Users/axeli/Desktop/SeminarioPagina/build/web/WEB-INF/faces-config.xml': null

    28-Feb-2016 18:00:19.275 INFO [http-nio-8084-exec-10] org.apache.catalina.util.LifecycleBase.stop The stop() method was called on component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]] after stop() had already been called. The second call will be ignored.
    28-Feb-2016 18:00:19.777 INFO [http-nio-8084-exec-10] org.apache.catalina.startup.HostConfig.undeploy Repliegue (undeploy) de la aplicación web que tiene como trayectoria de contexto 
    28-Feb-2016 18:00:19.878 INFO [http-nio-8084-exec-10] org.apache.catalina.startup.HostConfig.deployDescriptor Desplieque del descriptor de configuración C:\Users\axeli\AppData\Roaming\NetBeans\8.1\apache-tomcat-8.0.27.0_base\conf\Catalina\localhost\ROOT.xml
    28-Feb-2016 18:00:19.878 WARNING [http-nio-8084-exec-10] org.apache.catalina.startup.SetContextPropertiesRule.begin [SetContextPropertiesRule]Context Setting property 'antiJARLocking' to 'true' did not find a matching property.
    28-Feb-2016 18:00:20.826 INFO [http-nio-8084-exec-10] org.apache.jasper.servlet.TldScanner.scanJars Al menos un JAR, que se ha explorado buscando TLDs, aún no contenía TLDs. Activar historial de depuración para este historiador para una completa lista de los JARs que fueron explorados y de los que nos se halló TLDs. Saltarse JARs no necesarios durante la exploración puede dar lugar a una mejora de tiempo significativa en el arranque y compilación de JSP .
    28-Feb-2016 18:00:20.948 INFO [http-nio-8084-exec-10] com.sun.faces.config.ConfigureListener.contextInitialized Inicializando Mojarra 2.2.7 ( 20140610-1547 https://svn.java.net/svn/mojarra~svn/tags/2.2.7@13362) para el contexto ''
    28-Feb-2016 18:00:21.079 SEVERE [http-nio-8084-exec-10] com.sun.faces.config.ConfigureListener.contextInitialized Critical error during deployment: 
     com.sun.faces.config.ConfigurationException: java.util.concurrent.ExecutionException: com.sun.faces.config.ConfigurationException: Unable to parse document 'file:/C:/Users/axeli/Desktop/SeminarioPagina/build/web/WEB-INF/faces-config.xml': null
        at com.sun.faces.config.ConfigManager.getConfigDocuments(ConfigManager.java:761)
        at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:349)
        at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:221)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4736)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5181)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
        at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:586)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:460)
        at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1586)
        at sun.reflect.GeneratedMethodAccessor47.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
        at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
        at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1460)
        at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:906)
        at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:344)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:745)
    Caused by: java.util.concurrent.ExecutionException: com.sun.faces.config.ConfigurationException: Unable to parse document 'file:/C:/Users/axeli/Desktop/SeminarioPagina/build/web/WEB-INF/faces-config.xml': null
        at java.util.concurrent.FutureTask.report(FutureTask.java:122)
        at java.util.concurrent.FutureTask.get(FutureTask.java:192)
        at com.sun.faces.config.ConfigManager.getConfigDocuments(ConfigManager.java:759)
        ... 49 more
    Caused by: com.sun.faces.config.ConfigurationException: Unable to parse document 'file:/C:/Users/axeli/Desktop/SeminarioPagina/build/web/WEB-INF/faces-config.xml': null
        at com.sun.faces.config.ConfigManager$ParseTask.call(ConfigManager.java:1012)
        at com.sun.faces.config.ConfigManager$ParseTask.call(ConfigManager.java:954)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at com.sun.faces.config.ConfigManager.getConfigDocuments(ConfigManager.java:747)
        ... 49 more
    Caused by: java.lang.NullPointerException
        at com.sun.faces.config.ConfigManager$ParseTask.getDocument(ConfigManager.java:1172)
        at com.sun.faces.config.ConfigManager$ParseTask.call(ConfigManager.java:1003)
        ... 52 more

    28-Feb-2016 18:00:21.195 SEVERE [http-nio-8084-exec-10] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
    28-Feb-2016 18:00:21.195 SEVERE [http-nio-8084-exec-10] org.apache.catalina.core.StandardContext.startInternal Falló en arranque del Contexto [] debido a errores previos
    28-Feb-2016 18:00:21.227 SEVERE [http-nio-8084-exec-10] javax.faces.FactoryFinder$FactoryManager.copyInjectionProviderFromFacesContext Unable to obtain InjectionProvider from init time FacesContext. Does this container implement the Mojarra Injection SPI?
    28-Feb-2016 18:00:21.227 SEVERE [http-nio-8084-exec-10] javax.faces.FactoryFinder$FactoryManager.getFactory La aplicación no se ha inicializado correctamente durante el inicio, no se encuentra la fábrica: javax.faces.application.ApplicationFactory. Attempting to find backup.
    28-Feb-2016 18:00:21.227 SEVERE [http-nio-8084-exec-10] com.sun.faces.config.ConfigureListener.contextDestroyed Unexpected exception when attempting to tear down the Mojarra runtime
     java.lang.IllegalStateException: Could not find backup for factory javax.faces.application.ApplicationFactory. 
        at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:1135)
        at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:379)
        at com.sun.faces.config.InitFacesContext.getApplication(InitFacesContext.java:142)
        at com.sun.faces.config.ConfigureListener.contextDestroyed(ConfigureListener.java:319)
        at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4783)
        at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5404)
        at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
        at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:586)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:460)
        at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1586)
        at sun.reflect.GeneratedMethodAccessor47.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
        at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
        at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1460)
        at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:906)
        at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:344)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:745)

    28-Feb-2016 18:00:21.358 SEVERE [http-nio-8084-exec-10] javax.faces.FactoryFinder.releaseFactories Unable to call @PreDestroy annotated methods because no InjectionProvider can be found. Does this container implement the Mojarra Injection SPI?
    28-Feb-2016 18:00:21.390 INFO [http-nio-8084-exec-10] org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of configuration descriptor C:\Users\axeli\AppData\Roaming\NetBeans\8.1\apache-tomcat-8.0.27.0_base\conf\Catalina\localhost\ROOT.xml has finished in 1.512 ms

这些是我现在正在使用的库:

【问题讨论】:

请添加您的 faces.config.xml 文件。无论如何请谷歌大量与此问题相关的答案***.com/questions/16124684/… 【参考方案1】:

com.sun.faces.config.ConfigManager$ParseTask.getDocument(ConfigManager.java:1172) 处的 java.lang.NullPointerException

这通常只发生在 faces-config.xml 本身存在 XML 语法错误并且 XML 解析器(错误地)没有抛出异常而只是返回 null 时。仔细注意文档的 XML 格式良好。 IE。每个<element> 必须有一个匹配的</element>,每个" 必须有一个匹配的",等等。

如果您使用的是 IDE,请确保它具有必要的 JSF/Java EE 插件,这些插件通常负责 XML 验证。或者,如果您已经拥有,请注意 IDE 中的错误/警告。如果您不确定,请将faces-config.xml 复制粘贴到某些online XML validation tool 中,例如http://www.xmlvalidation.com。

【讨论】:

正如你所说,我的faces-config.xml 中有错误。谢谢@BalusC【参考方案2】:

由于某些原因,如果 faces-config 的 version 属性(可能还有命名空间 defs)对于应用程序服务器来说太高而无法处理,也会发生这种情况。

我在尝试使用 JSF 2.2 的古老 Glassfish 3 上以某种方式发现了这一点,而它只对 2.0 或 2.1 感到满意。

希望这可以帮助人们减少在这方面浪费的时间。

对于任何决定返回 null 作为有用信息的人:...实际上,我没什么好说的。


我知道应该可以升级 Glassfish 3 的库以支持 JSF 2.2,但是这还没有完成。

【讨论】:

以上是关于无法在 JSF 应用程序中解析文档 faces-config.xml的主要内容,如果未能解决你的问题,请参考以下文章

扩展与复选框相关的 jsf 组件时出现“无法解析类型 javax.el.ValueExpression”错误

Spring boot JSF可执行JAR找不到xhtml文件

jsf 2.0 上的 JSF1064“无法找到或提供资源”警告

JSF 不解析 # 标签

JSF 2.0。无法在 preRenderView 事件处理程序中获取 POST 参数和 cookie

如何在 Eclipse 中查看 jsf/facelets 元素的文档