java.lang.IllegalArgumentException:空源 [英] java.lang.IllegalArgumentException: null source
问题描述
我们有一个使用JSF2和Spring的应用程序.部署后,该应用程序可以正常运行.但是,如果执行以下步骤,就会发生这种情况:
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.
有人知道答案吗?
推荐答案
这个应该已经作为ViewExpiredException
抛出了.这是一个错误,该错误开始在Mojarra 2.0.3中显现,并已在Mojarra 2.1.0中修复.另请参见问题1762 (请注意,Mojarra 2.1.0
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).
基本上,当Mojarra无法构建或还原视图时,通常会抛出足够具体的异常,但是由于此错误,以后在代码中错误地期望出现有效视图,从而导致生成IllegalArgumentException: null source
. real 的可能原因是该视图包含一个简单的XML语法错误,例如缺少标签或属性值损坏,为此Mojarra通常会抛出带有非常详细消息的FaceletException
带有行号和位置等.
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 a FaceletException
with a very detailed message with line number and position and such.
为防止出现ViewExpiredException
,您必须在执行任何操作之前通过GET请求刷新页面.如果您使用的Mojarra版本没有发现此错误(例如2.0.2或更旧版本,或者2.1.0或更高版本),则可以在特定异常下使用web.xml
中的<error-page>
优雅地处理它,并且提供一个自定义错误页面,其中通知最终用户会话已过期,以及指向初始请求URI的链接.
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>
in web.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.
这篇关于java.lang.IllegalArgumentException:空源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!