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?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Ikthiander
  • 3,917
  • 8
  • 37
  • 54

4 Answers4

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.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • I am having exact same issue right now, i will update my mojarra version and see if i get similar kind of issue. – Rachel Mar 12 '12 at 19:59
  • 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 Mar 12 '12 at 20:07
  • @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 http://stackoverflow.com/tags/viewexpiredexception/info – BalusC Mar 12 '12 at 20:10
  • 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 Mar 12 '12 at 20:25
  • 1
    @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. – BalusC Mar 12 '12 at 20:29
  • yeah, i am working on that upgrade, between i was looking around and it seems that 2.1.0 has some other set of puzzles with it, https://community.jboss.org/thread/174379?_sscc=t, https://community.jboss.org/thread/160868 – Rachel Mar 12 '12 at 20:33
  • @Rachel: that's also an old version :) I said **at least** 2.1.0. It's fixed since that version. The newer versions of course doesn't have this bug anymore. Currently it's at 2.1.7. You should of course pick the latest version. – BalusC Mar 12 '12 at 20:34
  • I will update my experiences in here, thanks for useful information. – Rachel Mar 12 '12 at 20:48
  • +1 for revisiting and answering comments for already selected answer, thanks BalusC. – Rachel Mar 12 '12 at 20:49
  • https://community.jboss.org/thread/174379 details some issues that i am facing, mojarra 2.0 has jboss-faces.jar, jsf-api-2.0.3-b05.jar and jsf-impl-2.0.3-b05.jar and i have download javax.faces-2.1.7.jar, my consfusion is that in jsf-libs, do i add only javax.faces-2.1.7.jar or i need to have other jar's like jboss-faces.jar, jsf-api-2.1.7-b05.jar and jsf-impl-2.1.7-b05.jar also? – Rachel Mar 15 '12 at 17:34
  • @Rachel: You should definitely keep `jboss-faces.jar`. This one takes care the JBoss JSF deployment. The others are JSF impl specific libs and needs to be removed when you have a newer version. The `javax.faces.jar` is a since Mojarra 2.1.5 new bundle file which contains **both** the API and impl. So use *either* this one, *or* the separate API/impl files. Oh, in the future please ask a new question. This is offtopic. – BalusC Mar 15 '12 at 17:37
  • Sure I will, also i was wrong in my understanding regarding sessions, I have added comment to http://stackoverflow.com/q/9705443/164299. – Rachel Mar 15 '12 at 17:50
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.

Manuel
  • 3,828
  • 6
  • 33
  • 48
3

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

which is not fixed in Mojarra 2.1.x

Roger Keays
  • 3,117
  • 1
  • 31
  • 23
-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

Masoud
  • 63
  • 8