title: JSF selectItems value from sql query
body: <p>I want to populate selectOneMenu component with values extracted from database by sql query.
  Query returns only store names which I want to enter as values to selectOneMenu</p>
  
  <p>I get java.lang.IllegalArgumentException with stack starting with :</p>
  
  <pre><code>java.lang.IllegalArgumentException  at         com.sun.faces.renderkit.SelectItemsIterator.initializeItems(SelectItemsIterator.java:216)
  at com.sun.faces.renderkit.SelectItemsIterator.hasNext(SelectItemsIterator.java:135)
  at com.sun.faces.renderkit.html_basic.MenuRenderer.renderOptions(MenuRenderer.java:762)
  </code></pre>
  
  <p>This is my xhtml code (This is the only use of selectItems):</p>
  
  <pre><code>&lt;h:selectOneMenu id="storeName"   value="#{shoplist.store}"&gt;  
     &lt;f:selectItems value="#{buyHistory.stores}" /&gt;
  &lt;/h:selectOneMenu&gt;
  </code></pre>
  
  <p>This is query from buyHistory bean:</p>
  
  <pre><code>public ResultSet getStores() throws SQLException {
  ...
  PreparedStatement getStores = connection.prepareStatement( 
                  "SELECT distinct STORE_NAME  "
                  + "FROM BuyingHistory ORDER BY STORE_NAME");
  CachedRowSet rowSet = new com.sun.rowset.CachedRowSetImpl();
  rowSet.populate(getStores.executeQuery());
  return rowSet;
  }
  </code></pre>
  
  <p>What am I doing wrong? Should I convert somehow from resultSet to SelectItem array/list? </p>