title: java.lang.NullPointerException at org.primefaces.component.menubar.MenubarRenderer.encodeSubmenuIcon
body: <p>I am working at a primefaces dynamic menubar. 
  The content of the menubar should be updated as a commandbutton is pressed.</p>
  
  <p>Here is my very simple xhtml page</p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:p="http://primefaces.org/ui"&gt;
  &lt;h:head&gt;
      &lt;title&gt;CoSMo&lt;/title&gt;
  &lt;/h:head&gt;
  &lt;h:body&gt;
      #{simpleMenuBacking.init()}
      &lt;h:form&gt;
          &lt;p:commandButton value="Submit" action="#{simpleMenuBacking.updateModel()}" update="mb1"/&gt;
          &lt;p:growl id="messages" showDetail="false"/&gt;
          &lt;p:menubar id="mb1" model="#{simpleMenuBacking.model}" /&gt;
      &lt;/h:form&gt; 
  
  &lt;/h:body&gt;
  </code></pre>
  
  <p></p>
  
  <p>And my (accordingly simple) backing bean:</p>
  
  <pre><code>@Named
  @SessionScoped
  public class SimpleMenuBacking implements Serializable {
  
      private DefaultMenuModel model;
  
      public void init() {
      Logger.getLogger(UserBacking.class.getName()).info("[SimpleMenuBacking.init()] Starting.");
  
          model = new DefaultMenuModel();
  
          String myMenuEntry = "MENU ENTRY " + new Random().nextInt();
          Logger.getLogger(UserBacking.class.getName()).info(myMenuEntry);
          model.addElement(new DefaultSubMenu(myMenuEntry));
      }
  
      public SimpleMenuBacking() {
      }
  
      public DefaultMenuModel getModel() {
           Logger.getLogger(UserBacking.class.getName()).info("[SimpleMenuBacking.getModel()] Starting.");
          return model;
      }
  
      public void updateModel() {
  
          Logger.getLogger(UserBacking.class.getName()).info("[SimpleMenuBacking.updateModel()] Starting.");
  
          String myMenuEntry = "MENU ENTRY " + new Random().nextInt();
          model.addElement(new DefaultSubMenu(myMenuEntry));
  
          Logger.getLogger(UserBacking.class.getName()).info("[SimpleMenuBacking.updateModel()] Over.");
      }
  
  }
  </code></pre>
  
  <p>Unfortunately, as i press the commandbutton, the <strong>model of the menubar is updated, but the changes are not rendered</strong> within the menubar. I figured out that the following exception might almost certainly be the cause of the issue:</p>
  
  <pre><code>SEVERE:   Error Rendering View[/index.xhtml]
  java.lang.NullPointerException
  at org.primefaces.component.menubar.MenubarRenderer.encodeSubmenuIcon(MenubarRenderer.java:60)
  at org.primefaces.component.tieredmenu.TieredMenuRenderer.encodeSubmenu(TieredMenuRenderer.java:161)
  at org.primefaces.component.tieredmenu.TieredMenuRenderer.encodeElements(TieredMenuRenderer.java:127)
  at org.primefaces.component.tieredmenu.TieredMenuRenderer.encodeMenu(TieredMenuRenderer.java:78)
  at org.primefaces.component.menubar.MenubarRenderer.encodeMarkup(MenubarRenderer.java:50)
  at org.primefaces.component.menu.BaseMenuRenderer.encodeEnd(BaseMenuRenderer.java:108)
  at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:924)
  at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
  at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:559)
  at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183)
  ...
  </code></pre>
  
  <p>How is this caused and how can I solve it?
  I am willing to give further details about my code and/or project settings. Thanks.</p>