Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
667 views
in Technique[技术] by (71.8m points)

jsf - java.lang.IllegalArgumentException: null source

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:

  1. Open the login page of the application.
  2. Redeployed the application on the server.
  3. 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 a FaceletException 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> 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...