javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-2642

Mojarra 2.1.16 still gives 500 error instead of 404 for non-exist resources

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.16
    • Fix Version/s: 2.2.0-m08, 2.1.17
    • Component/s: resources
    • Labels:
      None
    • Environment:

      Glassfish web profile: 3.1.2, Weld: 1.1.5, OS: Ubuntu 12.04 x64, Java: JDK 7u12

      Description

      The right URL is:http://host/path/page.jsf

      If I access the jsf page URL by mistake like: http://host/path/page1.jsf

      It changed the jsf extension to JSP by itself, and then triggered 500 error.
      The log says:

      SEVERE: PWC6117: File "/path/page1.jsp" not found
      WARNING: StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
      java.lang.NullPointerException
      at com.sun.faces.context.flash.ELFlash.doLastPhaseActions(ELFlash.java:607)
      at com.sun.faces.context.ExternalContextImpl.responseFlushBuffer(ExternalContextImpl.java:899)
      at com.sun.faces.application.view.JspViewHandlingStrategy.buildView(JspViewHandlingStrategy.java:154)
      at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:99)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
      at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
      at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
      at com.sun.grizzly.arp.DefaultAsyncExecutor.execute(DefaultAsyncExecutor.java:159)
      at com.sun.grizzly.arp.DefaultAsyncExecutor.interrupt(DefaultAsyncExecutor.java:145)
      at com.sun.grizzly.arp.AsyncProcessorTask.doTask(AsyncProcessorTask.java:102)
      at com.sun.grizzly.http.TaskBase.run(TaskBase.java:193)
      at com.sun.grizzly.http.TaskBase.execute(TaskBase.java:175)
      at com.sun.grizzly.arp.DefaultAsyncHandler.handle(DefaultAsyncHandler.java:145)
      at com.sun.grizzly.arp.AsyncProtocolFilter.execute(AsyncProtocolFilter.java:210)
      at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
      at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
      at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
      at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
      at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
      at java.lang.Thread.run(Thread.java:722)

      But if the URL is: http://host/path/page1.xhtml
      then the 404 error is issued, and the log shows:

      WARNING: StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
      com.sun.faces.context.FacesFileNotFoundException: /path/page1.xhtml Not Found in ExternalContext as a Resource
      at com.sun.faces.facelets.impl.DefaultFaceletFactory.resolveURL(DefaultFaceletFactory.java:231)
      at com.sun.faces.facelets.impl.DefaultFaceletFactory.resolveURL(DefaultFaceletFactory.java:272)
      at com.sun.faces.facelets.impl.DefaultFaceletFactory.getMetadataFacelet(DefaultFaceletFactory.java:208)
      at com.sun.faces.application.view.ViewMetadataImpl.createMetadataView(ViewMetadataImpl.java:113)
      at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:233)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
      at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
      at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
      at com.sun.grizzly.arp.DefaultAsyncExecutor.execute(DefaultAsyncExecutor.java:159)
      at com.sun.grizzly.arp.DefaultAsyncExecutor.interrupt(DefaultAsyncExecutor.java:145)
      at com.sun.grizzly.arp.AsyncProcessorTask.doTask(AsyncProcessorTask.java:102)
      at com.sun.grizzly.http.TaskBase.run(TaskBase.java:193)
      at com.sun.grizzly.http.TaskBase.execute(TaskBase.java:175)
      at com.sun.grizzly.arp.DefaultAsyncHandler.handle(DefaultAsyncHandler.java:145)
      at com.sun.grizzly.arp.AsyncProtocolFilter.execute(AsyncProtocolFilter.java:210)
      at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
      at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
      at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
      at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
      at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
      at java.lang.Thread.run(Thread.java:722)

      The web.xml contains:
      <context-param>
      <param-name>javax.faces.FACELETS_SUFFIX</param-name>
      <param-value>.xhtml</param-value>
      </context-param>

      and

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

        Activity

        Hide
        Manfred Riem added a comment -

        Can you please attach an example application (with sources) that demonstrates the problem?

        Show
        Manfred Riem added a comment - Can you please attach an example application (with sources) that demonstrates the problem?
        Hide
        nullone added a comment -

        My web app uses Primefaces 3.2, and facelet instead of jsp.

        So the question is:
        the actual web page is page.xhtml, and the its access URL is /path/page.jsf, but Mojarra 2.1.16 (I also tested 2.1.9 and 2.1.14) will think page1.jsf is mapped to page1.jsp, and then throws out NPE exception.

        If the wrong URL is page1.xhtml, then mojarra will pick up its sanity, and honestly throws out com.sun.faces.context.FacesFileNotFoundException.

        Ken

        Show
        nullone added a comment - My web app uses Primefaces 3.2, and facelet instead of jsp. So the question is: the actual web page is page.xhtml, and the its access URL is /path/page.jsf, but Mojarra 2.1.16 (I also tested 2.1.9 and 2.1.14) will think page1.jsf is mapped to page1.jsp, and then throws out NPE exception. If the wrong URL is page1.xhtml, then mojarra will pick up its sanity, and honestly throws out com.sun.faces.context.FacesFileNotFoundException. Ken
        Hide
        Manfred Riem added a comment -

        Applied to 2.1 branch,

        svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-2642, r=rogerk, Guard against FacesContext.getCurrentInstance() return null."
        Sending jsf-ri\src\main\java\com\sun\faces\context\ExternalContextImpl.java
        Transmitting file data .
        Committed revision 11176.

        Show
        Manfred Riem added a comment - Applied to 2.1 branch, svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-2642 , r=rogerk, Guard against FacesContext.getCurrentInstance() return null." Sending jsf-ri\src\main\java\com\sun\faces\context\ExternalContextImpl.java Transmitting file data . Committed revision 11176.
        Hide
        Manfred Riem added a comment -

        Applied to 2.2 trunk,

        svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-2642, r=rogerk, Guard against FacesContext.getCurrentInstance() return null."
        Sending jsf-ri\src\main\java\com\sun\faces\context\ExternalContextImpl.java
        Transmitting file data .
        Committed revision 11177.

        Show
        Manfred Riem added a comment - Applied to 2.2 trunk, svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-2642 , r=rogerk, Guard against FacesContext.getCurrentInstance() return null." Sending jsf-ri\src\main\java\com\sun\faces\context\ExternalContextImpl.java Transmitting file data . Committed revision 11177.
        Hide
        Manfred Riem added a comment -

        Applied to 2.2 trunk,

        svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-2642, r=rogerk, Guard against FacesContext.getCurrentInstance() return null."
        Sending jsf-ri\src\main\java\com\sun\faces\context\ExternalContextImpl.java
        Transmitting file data .
        Committed revision 11179.

        Show
        Manfred Riem added a comment - Applied to 2.2 trunk, svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-2642 , r=rogerk, Guard against FacesContext.getCurrentInstance() return null." Sending jsf-ri\src\main\java\com\sun\faces\context\ExternalContextImpl.java Transmitting file data . Committed revision 11179.
        Hide
        Lynx6 added a comment -

        I'm using the version 2.1.17 and got this Exception when I changed index.xhtml to indexs.xhtml:

        com.sun.faces.context.FacesFileNotFoundException: /ponderacion/indicadores/indexs.xhtml Not Found in ExternalContext as a Resource
        at com.sun.faces.facelets.impl.DefaultFaceletFactory.resolveURL(DefaultFaceletFactory.java:231)
        at com.sun.faces.facelets.impl.DefaultFaceletFactory.resolveURL(DefaultFaceletFactory.java:287)
        at com.sun.faces.facelets.impl.DefaultFaceletFactory.getMetadataFacelet(DefaultFaceletFactory.java:208)
        at com.sun.faces.application.view.ViewMetadataImpl.createMetadataView(ViewMetadataImpl.java:113)
        at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:233)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
        at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
        at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)

        Manfred, can you check again this issue, I need JSF return a 404 error in this case, not 500.

        Show
        Lynx6 added a comment - I'm using the version 2.1.17 and got this Exception when I changed index.xhtml to indexs.xhtml: com.sun.faces.context.FacesFileNotFoundException: /ponderacion/indicadores/indexs.xhtml Not Found in ExternalContext as a Resource at com.sun.faces.facelets.impl.DefaultFaceletFactory.resolveURL(DefaultFaceletFactory.java:231) at com.sun.faces.facelets.impl.DefaultFaceletFactory.resolveURL(DefaultFaceletFactory.java:287) at com.sun.faces.facelets.impl.DefaultFaceletFactory.getMetadataFacelet(DefaultFaceletFactory.java:208) at com.sun.faces.application.view.ViewMetadataImpl.createMetadataView(ViewMetadataImpl.java:113) at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:233) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217) Manfred, can you check again this issue, I need JSF return a 404 error in this case, not 500.

          People

          • Assignee:
            Manfred Riem
            Reporter:
            nullone
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

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