Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-3557

ViewNotFoundException using Custom Exception Handler after ViewExpiredException when using implicit navigation and prefix mapping.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.13
    • 2.0.14, 2.1.8
    • JSR-314
    • None
    • WebSphere Application Server 8.0 using MyFaces 2.0.13

    Description

      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 "/" prefix 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 of the current view.

      It is also worth taking note in that fact that this only looks to really matter when using prefix mapping since the algo. in 7.5.2 differs for prefix and suffix mapping.

      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!

      Attachments

        1. NavigationHandlerImplTest.patch
          1 kB
          Paul Nicolucci
        2. NavigationHandlerImpl.patch
          3 kB
          Paul Nicolucci
        3. MYFACES-3557-2.patch
          11 kB
          Leonardo Uribe

        Activity

          People

            lu4242 Leonardo Uribe
            paul.nicolucci Paul Nicolucci
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 24h
                24h
                Remaining:
                Remaining Estimate - 24h
                24h
                Logged:
                Time Spent - Not Specified
                Not Specified