title: WHY? - completeMethod="#{testBean.itemList}": Method not found
body: <p>I need your collective expertise... <em>(thankyou for any guidance you can provide me!!)</em></p>
  
  <p><em><strong>Problem:</em></strong>  My PrimeFaces "<strong><em>p:autocomplete</em></strong>" tag is generating a "<strong><em>Method not found</em></strong>" error on the "<strong><em>completeMethod</em></strong>" attribute...   --However, this method clearly appears to exist in the "<strong><em>TestBean</em></strong>" backing bean!  </p>
  
  <p><em><strong>Question:</em></strong>  What is the cause of the error?<br>
  <em>(FWIW: Using this tag seemed to be a fairly intuitive task...at first.   --But, I am apparently fundamentally misunderstanding something...I just dont know what).</em></p>
  
  <p><em><strong>Here is the error message...</em></strong></p>
  
  <pre><code>WARNING: /index.xhtml @17,215 completeMethod="#{testBean.itemList}": Method not found: aaa.bbb.ccc.war.TestBean@13a494d.itemList(java.lang.String)
  javax.el.MethodNotFoundException: /index.xhtml @17,215 completeMethod="#{testBean.itemList}": Method not found: aaa.bbb.ccc.war.TestBean@13a494d.itemList(java.lang.String)
      at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:109)
      at org.primefaces.component.autocomplete.AutoComplete.broadcast(AutoComplete.java:358)
  </code></pre>
  
  <p><strong>here is the facelet page containing the p:autocomplete tag...</strong></p>
  
  <pre><code>&lt;?xml version='1.0' encoding='UTF-8' ?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:util="http://java.sun.com/jsf/composite/util"      
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:c="http://java.sun.com/jsp/jstl/core"
        xmlns:p="http://primefaces.org/ui"&gt;      
      &lt;f:view contentType="text/html"&gt;
          &lt;h:head&gt;
              &lt;title&gt;testprimeac&lt;/title&gt;
              &lt;meta charset="utf-8" /&gt;
          &lt;/h:head&gt;
          &lt;h:body&gt;
              &lt;h:form id="form1"&gt;
                  &lt;p:autoComplete id="abc"  dropdown="true" value="#{testBean.item}" completeMethod="#{testBean.itemList}" var="item" itemLabel="#{item.itemLabel}" itemValue="#{item.itemValue}" forceSelection="true"&gt;&lt;/p:autoComplete&gt;
              &lt;/h:form&gt;
          &lt;/h:body&gt;
      &lt;/f:view&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>Here is the "TestBean" backing bean that contains the method in question <em>(or so I thought)</em>...</strong></p>
  
  <pre><code>package aaa.bbb.ccc.war;
  
  import java.io.IOException;
  import java.io.Serializable;
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.Iterator;
  import java.util.LinkedHashMap;
  import java.util.List;
  import java.util.Map;
  import java.util.logging.Level;
  import javax.faces.context.FacesContext;
  import org.springframework.context.annotation.Scope;
  import org.springframework.stereotype.Component;
  
  @Component("testBean")
  @Scope("request")
  public class TestBean implements Serializable
  {
      public TestBean()
      {
      }
  
      private static final Map&lt;String, String&gt; listBoxEntryMap;
      static
      {
          Map&lt;String, String&gt; m = new LinkedHashMap&lt;String, String&gt;();
          m.put("aaavalue", "aaalabel");
          m.put("bbbvalue", "aablabel");
          m.put("cccvalue", "abblabel");
          m.put("dddvalue", "bbblabel");
          m.put("eeevalue", "bbclabel");
          m.put("fffvalue", "bcclabel");
          m.put("gggvalue", "ccclabel");
          m.put("hhhvalue", "ccalabel");
          m.put("iiivalue", "caalabel");
          m.put("jjjvalue", "aaclabel");
          m.put("kkkvalue", "acclabel");
          m.put("lllvalue", "bbalabel");
          m.put("mmmvalue", "baalabel");
  
          listBoxEntryMap = Collections.unmodifiableMap(m);
      }
  
      private Item item;
      public Item getItem()
      {
          return this.item;
      }
  
      public void setItem(Item i)
      {
          this.item = i;
      }    
  
      private static List&lt;Item&gt; itemList = new ArrayList&lt;Item&gt;();
      public void setItemList(List&lt;Item&gt; data) throws IOException
      {
          itemList = (null==data?new ArrayList&lt;Item&gt;():data);
          FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("itemList",itemList);   
      }
      public static List&lt;Item&gt; getItemList()
      {
          if (null==itemList)
          {
              try
              {
                  if (FacesContext.getCurrentInstance().getExternalContext().getSessionMap().containsKey("itemList"))
                  {
                      itemList = (List&lt;Item&gt;) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("itemList");            
                  }
  
                  if (null == itemList || itemList.isEmpty())
                  {
                      itemList = getListOfItems();
                      FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("itemList",itemList);            
                  }
  
                  return itemList; //(list);
              }
              catch (Exception ex)
              {
                  java.util.logging.Logger.getLogger(TestBean.class.getName()).log(Level.SEVERE, null, ex);
              }
          }
  
          return itemList;
      }
  
      public static List&lt;Item&gt; getItemList(String s)
      {
          itemList = getItemList();
          List&lt;Item&gt; suggestions = new ArrayList&lt;Item&gt;();
  
          for (Item i : itemList)
          {
              if (i.getItemLabel().startsWith(s))
              {
                  suggestions.add(i);
              }
          }
  
          return suggestions;
      }    
  
  
      public static List&lt;Item&gt; getListOfItems()
      {
          List&lt;Item&gt; list = null;
          try
          {
              Map&lt;String, String&gt; map = listBoxEntryMap;
              Iterator iter = map.keySet().iterator();
  
              list = new ArrayList&lt;Item&gt;();
  
              while (iter.hasNext())
              {
                  String key = (String) iter.next();
                  String val = (String) map.get(key);
                  list.add(new Item(key,val));
              }
          }
          catch (Exception e)
          {
              System.out.println("Exception during query call..." + e.getMessage());
              e.printStackTrace();
          }
  
          return (null==list?new ArrayList&lt;Item&gt;():list);
      }
  }
  </code></pre>
  
  <p><strong>Here is the "Item" pojo class used with the autocomplete *(value and label are both strings, which I think means that a "converter" class is not required)</strong></p>
  
  <pre><code>package aaa.bbb.ccc.war;
  
  public class Item
  {
      public Item()
      {
      }
      public Item(String l, String v)
      {
          this.itemLabel = (null == l ? "" : l);
          this.itemValue = (null == v ? "" : v);
      }
      private String itemLabel = "";
      private String itemValue = "";
      @Override
      public String toString()
      {
          return (null == this.itemValue ? "" : this.itemValue);
      }
      public String getString()
      {
          return (null == this.itemValue ? "" : this.itemValue);
      }
      public String getItemLabel()
      {
          return (null == this.itemLabel ? "" : this.itemLabel);
      }
      public void setItemLabel(String s)
      {
          this.itemLabel = s;
      }
      public String getItemValue()
      {
          return (null == this.itemValue ? "" : this.itemValue);
      }
      public void setItemValue(String s)
      {
          this.itemValue = s;
      }
  }
  </code></pre>
  
  <p><strong>FWIW - here is the build pom.xml, to view dependencies/versions used...</strong></p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;aaa.bbb.ccc&lt;/groupId&gt;
      &lt;artifactId&gt;testprimeac-war&lt;/artifactId&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
      &lt;version&gt;1&lt;/version&gt;
      &lt;name&gt;testprimeac-war&lt;/name&gt;
      &lt;url&gt;http://maven.apache.org&lt;/url&gt;
      &lt;properties&gt;
          &lt;org.springframework-version&gt;3.1.1.RELEASE&lt;/org.springframework-version&gt;
          &lt;jsf-version&gt;2.1.11&lt;/jsf-version&gt;
      &lt;/properties&gt;    
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;commons-lang&lt;/groupId&gt;
              &lt;artifactId&gt;commons-lang&lt;/artifactId&gt;
              &lt;version&gt;2.6&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
              &lt;version&gt;2.5&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;jstl&lt;/artifactId&gt;
              &lt;version&gt;1.2&lt;/version&gt;
          &lt;/dependency&gt;                
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.faces&lt;/groupId&gt;
              &lt;artifactId&gt;jsf-api&lt;/artifactId&gt;
              &lt;version&gt;2.1.11&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.faces&lt;/groupId&gt;
              &lt;artifactId&gt;jsf-impl&lt;/artifactId&gt;
              &lt;version&gt;2.1.11&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.el&lt;/groupId&gt;
              &lt;artifactId&gt;el-api&lt;/artifactId&gt;
              &lt;version&gt;2.2&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.web&lt;/groupId&gt;
              &lt;artifactId&gt;el-impl&lt;/artifactId&gt;
              &lt;version&gt;2.2&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
              &lt;version&gt;${org.springframework-version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
              &lt;version&gt;${org.springframework-version}&lt;/version&gt;
          &lt;/dependency&gt;        
          &lt;dependency&gt;
              &lt;groupId&gt;org.primefaces&lt;/groupId&gt;
              &lt;artifactId&gt;primefaces&lt;/artifactId&gt;
              &lt;version&gt;3.4.2&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.6&lt;/source&gt;
                      &lt;target&gt;1.6&lt;/target&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.3&lt;/version&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
          &lt;finalName&gt;testprimeac-${project.version}&lt;/finalName&gt;       
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>