title: PrettyFaces error: Exception occured while building URL for MappingId [...], Required value [...] was null
body: <p>Pages in my JSF project that rely on PrettyFaces for URL re-writing suddenly gave me the following error, despite my not having changed anything directly related to PrettyFaces. What gives?</p>
  
  <pre><code>PrettyFaces: Exception occurred while building URL for MappingId &lt; my-page &gt;, Required value  &lt; #{myVar} &gt; was null
  </code></pre>
  
  <hr>
  
  <p>Here is the full stack trace:</p>
  
  <pre><code>javax.enterprise.event.ObserverException
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
      at java.lang.Class.newInstance0(Class.java:355)
      at java.lang.Class.newInstance(Class.java:308)
      at org.jboss.weld.util.reflection.SecureReflections$16.work(SecureReflections.java:343)
      at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
      at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInstantiation(SecureReflectionAccess.java:173)
      at org.jboss.weld.util.reflection.SecureReflections.newInstance(SecureReflections.java:340)
      at org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:33)
      at org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:73)
      at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:162)
      at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:241)
      at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:229)
      at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:207)
      at org.jboss.weld.manager.BeanManagerImpl.notifyObservers(BeanManagerImpl.java:569)
      at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:559)
      at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:554)
      at org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:74)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
      at org.jboss.solder.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:74)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
      at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:175)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
      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.core.StandardHostValve.invoke(StandardHostValve.java)
      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$AdapterCallable.call(ContainerMapper.java:317)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
      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: javax.servlet.ServletException: PrettyFaces: Exception occurred while building URL for MappingId &lt; my-page &gt;, Required value  &lt; #{myVar} &gt; was null
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
      at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:145)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
      at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:807)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:671)
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:505)
      at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:476)
      at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:355)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:305)
      at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:137)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
      at org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65)
      ... 30 more
  Caused by: com.ocpsoft.pretty.PrettyException: PrettyFaces: Exception occurred while building URL for MappingId &lt; my-page &gt;, Required value  &lt; #{myVar} &gt; was null
      at com.ocpsoft.pretty.faces.beans.ExtractedValuesURLBuilder.buildURL(ExtractedValuesURLBuilder.java:69)
      at com.ocpsoft.pretty.faces.application.PrettyViewHandler.getActionURL(PrettyViewHandler.java:128)
      at javax.faces.application.ViewHandlerWrapper.getActionURL(ViewHandlerWrapper.java:185)
      at org.jboss.weld.jsf.ConversationAwareViewHandler.getActionURL(ConversationAwareViewHandler.java:100)
      at javax.faces.application.ViewHandlerWrapper.getActionURL(ViewHandlerWrapper.java:185)
      at com.sun.faces.renderkit.html_basic.FormRenderer.getActionStr(FormRenderer.java:232)
      at com.sun.faces.renderkit.html_basic.FormRenderer.encodeBegin(FormRenderer.java:135)
      at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:820)
      at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:302)
      at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:105)
      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1757)
      at com.sun.faces.renderkit.html_basic.CompositeRenderer.encodeChildren(CompositeRenderer.java:78)
      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1757)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
      at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
      at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
      at com.ocpsoft.pretty.faces.application.PrettyViewHandler.renderView(PrettyViewHandler.java:163)
      at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
      at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
      at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
      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)
      ... 46 more
  </code></pre>