title: javax.el.ELException: Can't set property 'propertyName' on class 'com.example.MrBean' to value 'null'
body: <p>In my .xhtml file, I have the following SelectOneMenu component:</p>
  
  <pre><code>&lt;ui:define name="formContent"&gt;
      &lt;h:selectOneMenu value="#{mrBean.itemCategoryID}"&gt;
          &lt;f:ajax render="abc def" execute="@this" listener="#{mrBean.getListOfItems}"&gt;&lt;/f:ajax&gt; 
          &lt;f:selectItem itemLabel="Choose one .." itemValue="0" noSelectionOption="true" /&gt;
          &lt;f:selectItems value="#{mrBean.itemCategories}" var="ic"
                         itemLabel="#{ic.name}" itemValue="#{ic.id}" /&gt;
      &lt;/h:selectOneMenu&gt;
  
  &lt;h:panelGrid id="abc" columns="3" border="1"&gt;
      &lt;h:outputText style="font-weight: bold" value="Name"/&gt; 
      &lt;h:outputText style="font-weight: bold" value="Producer" /&gt;
      &lt;h:outputText /&gt;
  &lt;/h:panelGrid&gt;    
  
  &lt;h:panelGroup id="def" &gt;
      &lt;ui:repeat value="#{mrBean.items}" var="i"&gt;
          &lt;h:form id="BuyItemForm"&gt;
              &lt;h:panelGrid columns="3" border="1"&gt;
                  &lt;h:outputText style="font-weight: normal" value="#{i.name}" /&gt; 
                  &lt;h:outputText style="font-weight: normal" value="#{i.producer.name}" /&gt; 
                  &lt;h:commandButton value="Buy" actionListener="#{mrBean.buyItem}" &gt;
                      &lt;f:param name="itemID" value="#{i.id}" /&gt;
                  &lt;/h:commandButton&gt; 
  
              &lt;/h:panelGrid&gt;
          &lt;/h:form&gt;
      &lt;/ui:repeat&gt;
  &lt;/h:panelGroup&gt;
  &lt;/ui:define&gt;
  </code></pre>
  
  <p>When I open the page, it can load normally with the menu populated properly. However, when I choose 1 of the option, I ran into the following error:</p>
  
  <pre><code>SEVERE: javax.faces.component.UpdateModelException: javax.el.ELException: /partner/BuyItem.xhtml @53,81 value="#{mrBean.itemCategoryID}": Can't set property 'itemCategoryID' on class 'managedBean.MrBean' to value 'null'.
  ... 
  Caused by: javax.el.ELException: /partner/BuyItem.xhtml @53,81 value="#{mrBean.itemCategoryID}": Can't set property 'itemCategoryID' on class 'managedBean.MrBean' to value 'null'.
      at com.sun.faces.facelets.el.TagValueExpression.setValue(TagValueExpression.java:139)
      at javax.faces.component.UIInput.updateModel(UIInput.java:818)
      ... 47 more
  Caused by: java.lang.IllegalArgumentException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at javax.el.BeanELResolver.setValue(BeanELResolver.java:381)
      at com.sun.faces.el.DemuxCompositeELResolver._setValue(DemuxCompositeELResolver.java:255)
      at com.sun.faces.el.DemuxCompositeELResolver.setValue(DemuxCompositeELResolver.java:281)
      at com.sun.el.parser.AstValue.setValue(AstValue.java:197)
      at com.sun.el.ValueExpressionImpl.setValue(ValueExpressionImpl.java:286)
      at com.sun.faces.facelets.el.TagValueExpression.setValue(TagValueExpression.java:131)
      ... 48 more
  </code></pre>
  
  <p><strong>EDIT</strong>: this is my bean with getListOfItems function:</p>
  
  <pre><code>@ManagedBean
  @ViewScoped
  public class MrBean {
      @EJB
      private PartnerBeanLocal partnerBean;
  
      @ManagedProperty(value="0")
      private long    itemCategoryID;
      private List&lt;ItemState&gt; items;
  
      ...
      public void getListOfItems() {
          try {
              System.out.println(itemCategoryID); // I never saw this line printed out
              ArrayList data = partnerBean.getInfo(Constants.GET_LIST_OF_ITEMS, itemCategoryID);
  
              int result = ((Integer) data.get(0)).intValue();
              if (result == Constants.STATUS_SUCCESSFUL) items = (List&lt;ItemState&gt;) data.get(1);
              else if (result == Constants.STATUS_NOT_FOUND) FacesContext.getCurrentInstance().getExternalContext().redirect("HomePage.xhtml");
  
          } catch (IOException ex) {
              Logger.getLogger(MrBean.class.getName()).log(Level.SEVERE, null, ex);
          }
      }
      ...
  
      // Getters and Setters
      ...
      public long getItemCategoryID() {
          return itemCategoryID;
      }
  
      public void setItemCategoryID(long itemCategoryID) {
          this.itemCategoryID = itemCategoryID;
      }
  
      public List&lt;ItemState&gt; getItems() {
          return items; 
      }
  
      public List&lt;ItemState&gt; setItems(List&lt;ItemState&gt; items) {
          this.items = items; 
      }
      ...
  }
  </code></pre>
  
  <p>I'd be very grateful if someone could give me an advice on how to tackle this problem.</p>
  
  <p><strong>EDIT 2</strong>: Thanks everyone for helping me! The problem was that I stupidly forgot to put the <code>&lt;f:ajax&gt;</code> tag inside a <code>&lt;h:form&gt;</code> tag. </p>