gpt4 book ai didi

jsf - org.omnifaces.facesviews.FacesViewsForwardingFilter 处的 NullPointerException

转载 作者:行者123 更新时间:2023-12-02 00:50:25 25 4
gpt4 key购买 nike

我在 WildFly 8.2 上运行 Java EE 7 应用程序。我使用 OmniFaces 1.8.1。我在与 FacesViewsForwardingFilter 相关的日志文件 NullPointerExceptions 中看到:

2015-02-11 15:42:22,870 ERROR [io.undertow.request] (default task-12) UT005023: Exception handling request to /login: java.lang.NullPointerException
at org.omnifaces.facesviews.FacesViewsForwardingFilter.doFilter(FacesViewsForwardingFilter.java:122) [omnifaces-1.8.1.jar:1.8.1-20140603]
at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:77) [omnifaces-1.8.1.jar:1.8.1-20140603]
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
2015-02-11 15:42:31,524 ERROR [io.undertow.request] (default task-15) UT005023: Exception handling request to /search.xhtml: java.lang.NullPointerException
at org.omnifaces.facesviews.FacesViewsForwardingFilter.doFilter(FacesViewsForwardingFilter.java:153) [omnifaces-1.8.1.jar:1.8.1-20140603]
at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:77) [omnifaces-1.8.1.jar:1.8.1-20140603]
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

在服务器启动期间我看到了这个:

2015-02-11 12:28:35,667 ERROR [io.undertow.request] (default task-3) UT005023: Exception handling request to /terms/index: java.lang.IllegalStateException: Illegal attempt to set ViewHandler after a response has been rendered.
at com.sun.faces.application.ApplicationImpl.setViewHandler(ApplicationImpl.java:583) [jsf-impl-2.2.8-jbossorg-1.jar:]
at javax.faces.application.ApplicationWrapper.setViewHandler(ApplicationWrapper.java:288) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
at org.jboss.as.jsf.injection.weld.ForwardingApplication.setViewHandler(ForwardingApplication.java:367) [wildfly-jsf-injection-8.2.0.Final.jar:8.2.0.Final]
at org.omnifaces.facesviews.FacesViewsForwardingFilter.init(FacesViewsForwardingFilter.java:95) [omnifaces-1.8.1.jar:1.8.1-20140603]
at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:111) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:85)

web.xml中的相关配置为:

<servlet>
<servlet-name>facesServlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>facesServlet</servlet-name>
<url-pattern>*.html</url-pattern>
<url-pattern>*.xhtml</url-pattern>
<url-pattern>/javax.faces.resource/*</url-pattern>
</servlet-mapping>
<context-param>
<param-name>org.omnifaces.FACES_VIEWS_SCAN_PATHS</param-name>
<param-value>/*.xhtml</param-value>
</context-param>

这是怎么造成的,如何解决?

最佳答案

这些 NPE 表明过滤器初始化失败。在服务器启动期间,您应该能够在日志中更早地找到线索。

2015-02-11 12:28:35,667 ERROR [io.undertow.request] (default task-3) UT005023: Exception handling request to /terms/index: java.lang.IllegalStateException: Illegal attempt to set ViewHandler after a response has been rendered.

那个IllegalStateException是一个有用的提示。 FacesViewsViewHandler通过 FacesViewsForwardingFilter 进入 OmniFaces 1.x在首次请求匹配 /*.xhtml 的 URL 时延迟初始化。但是,如果 FacesServlet 则由于该异常而失败。在过滤器之前调用。你那里有一个可疑的*.html映射将触发 FacesServlet而不触发过滤器。您是否有一个纯 HTML 页面作为欢迎文件等?为什么不将其重命名为 *.xhtml

无论如何,初始化排序错误是 fixed在 OmniFaces 2.0 中。因此,升级应该可以。

关于jsf - org.omnifaces.facesviews.FacesViewsForwardingFilter 处的 NullPointerException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28461210/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com