java.lang.IllegalArgumentException:空源
我们有一个使用 JSF2 和 Spring 的应用程序。该应用程序部署后工作正常。但是,如果我执行以下步骤,就会发生这种情况:
- 打开应用程序的登录页面。
- 在服务器上重新部署应用程序。
尝试使用之前打开的登录页面登录,但显示以下异常:
javax.servlet.ServletException:空源 在 javax.faces.webapp.FacesServlet.service(FacesServlet.java:321) 在org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237) 在 org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167) 根本原因 java.lang.IllegalArgumentException:空源 在 java.util.EventObject.
(EventObject.java:38) 在 javax.faces.event.SystemEvent. (SystemEvent.java:67) 在 javax.faces.event.ComponentSystemEvent. (ComponentSystemEvent.java:69) 在 javax.faces.event.PostRestoreStateEvent. (PostRestoreStateEvent.java:69) 在 com.sun.faces.lifecycle.RestoreViewPhase.deliverPostRestoreStateEvent(RestoreViewPhase.java:256) 在 com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:245) 在 com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97) 在com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:107) 在 com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114) 在 javax.faces.webapp.FacesServlet.service(FacesServlet.java:308)
如果我单击第一个登录页面,然后输入登录详细信息,则应用程序不会中断。仅当我尝试将先前加载的登录页面与新部署的应用程序一起使用时,才会发生这种情况。
有人知道答案吗?
We have an application which uses JSF2 and Spring. The application works fine when deployed. But this happens if I went through the following steps:
- Open the login page of the application.
- Redeployed the application on the server.
Tried to login using the previously opened login page, and it shows the following exception:
javax.servlet.ServletException: null source at javax.faces.webapp.FacesServlet.service(FacesServlet.java:321) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167) root cause java.lang.IllegalArgumentException: null source at java.util.EventObject.<init>(EventObject.java:38) at javax.faces.event.SystemEvent.<init>(SystemEvent.java:67) at javax.faces.event.ComponentSystemEvent.<init>(ComponentSystemEvent.java:69) at javax.faces.event.PostRestoreStateEvent.<init>(PostRestoreStateEvent.java:69) at com.sun.faces.lifecycle.RestoreViewPhase.deliverPostRestoreStateEvent(RestoreViewPhase.java:256) at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:245) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97) at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:107) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308)
If I click on the first login page and then enter the login details the application does not break. This only occurs if I try to use the previously loaded login page with the newly deployed application.
Anyone knows the answer?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这个应该作为
ViewExpiredException
抛出。这是一个在 Mojarra 2.0.3 中开始出现的错误,并在 Mojarra 2.1.0 中得到修复。另请参阅问题 1762(请注意,Mojarra 2.1.0 不适用于 Tomcat/Jetty,至少使用 Mojarra 2.1.1)。基本上,当 Mojarra 无法构建或恢复视图时,它通常会抛出一个足够具体的异常,但由于此错误,代码中稍后会错误地预期有效视图,从而导致
IllegalArgumentException: null source
。可能的真正原因是视图包含一个简单的 XML 语法错误,例如缺少标签或损坏的属性值,Mojarra 通常会抛出一个FaceletException
带有非常详细的消息,包括行号和位置等。为了防止
ViewExpiredException
,您必须通过 GET 请求刷新页面,然后再对其执行任何操作。如果您使用的 Mojarra 版本没有出现此错误(例如 2.0.2 或更低版本,或者 2.1.0 或更高版本),那么您可以使用
优雅地处理它> 在web.xml
中处理特定异常,并提供一个自定义错误页面,其中通知最终用户会话已过期,以及指向初始请求 URI 的链接。This one should have been thrown as a
ViewExpiredException
. It's a bug which started to manifest in Mojarra 2.0.3 and is been fixed in Mojarra 2.1.0. See also issue 1762 (note that Mojarra 2.1.0 doesn't work on Tomcat/Jetty, use at least Mojarra 2.1.1 then).Basically, when Mojarra fails to build or restore the view, then it usually throws a specific enough exception, but due to this bug, a valid view was incorrectly been expected later in the code which in turn results in
IllegalArgumentException: null source
. The possible real cause would have been that the view contains a simple XML syntax error, such as a missing tag or broken attribute value, for which Mojarra would usually have thrown aFaceletException
with a very detailed message with line number and position and such.To prevent the
ViewExpiredException
, you would have to refresh the page by a GET request before doing any actions on it. If you're using a Mojarra version where this bug does not manifest (e.g. 2.0.2 or older, or 2.1.0 or newer), then you could gracefully handle it with an<error-page>
inweb.xml
on the particular exception and provide a custom error page wherein the enduser is informed that the session has been expired, along with a link to the initial request URI.这看起来像 http://java.net/jira/browse/JAVASERVERFACES-1758
其中Mojarra 2.1.x 中未修复
This looks like http://java.net/jira/browse/JAVASERVERFACES-1758
which is not fixed in Mojarra 2.1.x
只要将javax.faces.PARTIAL_STATE_SAVING设置为false,您就会收到java.lang.IllegalArgumentException。如果您将javax.faces.PARTIAL_STATE_SAVING设置为true(并且您知道自己在做什么),您将获得“好旧的”javax.faces.application。 ViewExpiredException 返回。
As long as javax.faces.PARTIAL_STATE_SAVING is set to false you'll receive that java.lang.IllegalArgumentException. If you set javax.faces.PARTIAL_STATE_SAVING to true (and you know what you are doing) you will get the "good old" javax.faces.application.ViewExpiredException back.
就我而言,结果是我在 xhtml 文件中缺少 jstl 调用之一的结束标记。我正在使用选择标签,并且选择之间的时间标签之一没有结束标签
In my case turned out i had missing end tag in xhtml file for one of the jstl calls. i was using choose tag and one of the when tags in between choose did not have an end tag