10

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?

4 Answers 4

13

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.

Sign up to request clarification or add additional context in comments.

12 Comments

I am having exact same issue right now, i will update my mojarra version and see if i get similar kind of issue.
I am getting error page mentioned in my web.xml but I want to know about what is causing this issue and what could be an proper fix for it.
@Rachel: If you're asking about IllegalArgumentException: null source, as mentioned in 1st paragraph, it's a bug in Mojarra. Upgrade to at least 2.1.0. The 2nd paragraph explains what the bug is and another possible cause of IllegalArgumentException: null source when using Mojarra with this bug. The 3rd paragraph explains how to deal with the real exception, which is ViewExpiredException in OP's particular case. If you want more information about ViewExpiredException, check stackoverflow.com/tags/viewexpiredexception/info
I certainly do not have ViewExpiredException as my session is stored in cookies and i have not keep my page open for pretty long. Also just a thought, third parties based on jsf like icefaces, richfaces and primefaces should reduce development effort as well as configuration efforts, i have had some challenging time in getting it right.
@Rachel: then it's just the other possible cause: a syntax error in XHTML. Upgrade to at least 2.1.0, then you'll see the real exception.
|
3

This looks like http://java.net/jira/browse/JAVASERVERFACES-1758

which is not fixed in Mojarra 2.1.x

Comments

3

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.

Comments

-1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.