Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.IllegalArgumentException: null source

Tags:

jsf

jsf-2

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?

like image 443
Ikthiander Avatar asked Jan 25 '11 10:01

Ikthiander


3 Answers

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.

like image 95
BalusC Avatar answered Nov 18 '22 08:11

BalusC


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

which is not fixed in Mojarra 2.1.x

like image 29
Roger Keays Avatar answered Nov 18 '22 09:11

Roger Keays


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.

like image 3
Manuel Avatar answered Nov 18 '22 08:11

Manuel