Uploaded image for project: 'RichFaces'
  1. RichFaces
  2. RF-11809

NPE on clearSkinCaches after HttpServletRequest wrapping

    Details

    • Steps to Reproduce:
      Hide

      Wrap your HTTP Request in a PhaseListener at RESTORE_VIEW/before and do context.getExternalContext().setRequest(wrapper)
      then call a URL that triggers the wrapping.

      Show
      Wrap your HTTP Request in a PhaseListener at RESTORE_VIEW/before and do context.getExternalContext().setRequest(wrapper) then call a URL that triggers the wrapping.

      Description

      I have a homemade "pretty URL" mechanism I've been using on JSF1.2 and RF 3.3 in the past.
      It uses a phase listener that operates during RESTORE_VIEW/before.
      At the end of its parsing, it computes the "real" viewId to display and does:
      PrettyUrlRequestWrapper wrapper = new PrettyUrlRequestWrapper(request);
      wrapper.setViewId(computedViewId);
      context.getExternalContext().setRequest(wrapper);

      When I don't use it and call directly .jsf pages, all works fine with RF 4.1.0CR2.
      When I use it, I get this error:

      GRAVE: null
      javax.servlet.ServletException
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
      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 com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
      at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
      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.http.ProcessorTask.doProcess(ProcessorTask.java:746)
      at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
      at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
      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:662)
      Caused by: java.lang.NullPointerException
      at org.richfaces.skin.SkinFactoryImpl.clearSkinCaches(SkinFactoryImpl.java:94)
      at org.richfaces.skin.SkinFactoryPreRenderViewListener.processEvent(SkinFactoryPreRenderViewListener.java:35)
      at javax.faces.event.SystemEvent.processListener(SystemEvent.java:106)
      at com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:2168)
      at com.sun.faces.application.ApplicationImpl.invokeListenersFor(ApplicationImpl.java:2144)
      at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:302)
      at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:246)
      at javax.faces.application.ApplicationWrapper.publishEvent(ApplicationWrapper.java:670)
      at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:108)
      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)
      ... 26 more

      ATTENTION: StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
      java.lang.NullPointerException
      at org.richfaces.skin.SkinFactoryImpl.clearSkinCaches(SkinFactoryImpl.java:94)
      at org.richfaces.skin.SkinFactoryPreRenderViewListener.processEvent(SkinFactoryPreRenderViewListener.java:35)
      at javax.faces.event.SystemEvent.processListener(SystemEvent.java:106)
      at com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:2168)
      at com.sun.faces.application.ApplicationImpl.invokeListenersFor(ApplicationImpl.java:2144)
      at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:302)
      at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:246)
      at javax.faces.application.ApplicationWrapper.publishEvent(ApplicationWrapper.java:670)
      at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:108)
      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 com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
      at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
      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.http.ProcessorTask.doProcess(ProcessorTask.java:746)
      at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
      at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
      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:662)

      Well, clearSkinCackes uses only FacesContext.
      static void clearSkinCaches(FacesContext context)

      { context.getAttributes().remove(BASE_SKIN_KEY); context.getAttributes().remove(SKIN_KEY); }

      If you check on the debugger, FC is indeed null then. That's unexpected and I'm not sure this is normal.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                fabmars Fab Mars
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: