Paul Nicolucci created MYFACES-3557:
---------------------------------------

             Summary: ViewNotFoundException using Custom Exception Handler 
after ViewExpiredException when using implicit navigation and prefix mapping.
                 Key: MYFACES-3557
                 URL: https://issues.apache.org/jira/browse/MYFACES-3557
             Project: MyFaces Core
          Issue Type: Bug
          Components: JSR-314
    Affects Versions: 2.0.13
         Environment: WebSphere Application Server  8.0 using MyFaces 2.0.13
            Reporter: Paul Nicolucci


I have an application which was posted in MyFaces-3530 
(ViewExpiredException.war) which uses a custom ExceptionHandler to deal with a 
ViewExpiredException.  Everything looks to be working as expected with this 
when I'm using a Faces Servlet Mapping such
as the following (suffix mapping):

        <servlet-mapping>
                <servlet-name>Faces Servlet</servlet-name>
                <url-pattern>*.jsf</url-pattern>
         </servlet-mapping>


However if I use something such as this (prefix mapping):

        <servlet-mapping>
                <servlet-name>Faces Servlet</servlet-name>
                <url-pattern>/f/*</url-pattern>
        </servlet-mapping>

I get the following exception when doing implicit navigation in my Exception 
Handler such as:

        nav.handleNavigation(fc, null, "viewExpired");  // viewExpired.xhtml 
exists in the web application

Exception:
        Caused by: org.apache.myfaces.lifecycle.ViewNotFoundException: A view 
is required to execute RENDER_RESPONSE(6)
        at 
org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:62)
        at 
org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:239)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:191)

According to the JSF 2.0 specification specifically Section 7.4.2:
"If viewIdToTest does not have a “file extension”, take the file extension from 
the current viewId and append it
properly to viewIdToTest."

Since the viewId is null after the ViewExpiredException we don't have anything 
to grab the file extension from when using implicit navigation in this case.  

https://issues.apache.org/jira/browse/MYFACES-3530 , deals with a similar 
situation where we were not adding the "/" preview when the viewId was null. 

The only way I could determine the extension we should be using was to call " 
DefaultRestoreViewSupport.calculateViewId(FacesContext context)" this uses the 
RequestServletPath to determine the viewId.  

I've provided a patch for NavigationHandlerImpl as well as 
NavigationHandlerImplTest (As once the patch is applied we don't have all the 
information in the facesContext given the current test so we fail, however if 
we don't use implicit navigation in the test we can still test that we don't 
get any NPEs after a VEE )

If everyone can take a look at the patch and let me know what you think that 
would be very helpful.  I'm willing to make changes but I've tested this and it 
is currently working.  I'm looking to see if I missed any cases where this 
would not work.  Patch contains some comments to explain what is going on and 
actually added an additional log statement.

Thanks!

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


Reply via email to