Strange IllegalStateException with RichFaces/Ajax4JSF
bibinsga25 Feb 13, 2008 3:58 AMHi,
I am getting an IllegalStateException, which I have no clue, from my JSF/Richfaces implementation running on Tomcat 6.0.1
javax.faces.FacesException: #{customerSearch.doSearch}: /pages/includes/customer-search.jspx @35,352 action="#{customerSearch.doSearch}": java.lang.IllegalStateException com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:107) javax.faces.component.UICommand.broadcast(UICommand.java:383) org.ajax4jsf.component.AjaxActionComponent.broadcast(AjaxActionComponent.java:61) org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:184) org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:162) org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:350) com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97) com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251) com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117) javax.faces.webapp.FacesServlet.service(FacesServlet.java:244) org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141) org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281) java.lang.IllegalStateException com.sun.faces.context.FacesContextImpl.assertNotReleased(FacesContextImpl.java:428) com.sun.faces.context.FacesContextImpl.addMessage(FacesContextImpl.java:347) com.qwest.ufeed.vision.presentation.beans.CustomerSearch.doSearch(CustomerSearch.java:71) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:585) org.apache.el.parser.AstValue.invoke(AstValue.java:131) org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276) com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68) com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:69) com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91) javax.faces.component.UICommand.broadcast(UICommand.java:383) org.ajax4jsf.component.AjaxActionComponent.broadcast(AjaxActionComponent.java:61) org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:184) org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:162) org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:350) com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97) com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251) com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117) javax.faces.webapp.FacesServlet.service(FacesServlet.java:244) org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141) org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
The doSearch method in my managed bean is given below
public String doSearch(){ results=new ArrayList<SelectItem>(); if(keyword==null || keyword.trim().length()==0){ }else{ keyword=keyword.trim(); if(keyword.equals(WILDCARD_KEYWORD)){ results=convertListToSelect(getCustomerMgr().getCustomers()); }else if(searchBy.equals(DEFAULT_SEARCH_CLAUSE)){ results=convertListToSelect(findCustomerByPrefix(getCustomerMgr().getCustomers(),keyword.toLowerCase())); }else if(searchBy.equals(ID_SEARCH_CLAUSE)){ Collections.sort(getCustomerMgr().getCustomers()); int fndIdx=Collections.binarySearch(getCustomerMgr().getCustomers(), new Customer(keyword)); if(fndIdx>=0){ results=convertObjectToSelect(getCustomerMgr().getCustomers().get(fndIdx)); } } } if(results.size()==0){ visionContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO,"Password updated successfully","Password updated successfully")); } return null; }
I am getting this error when the results.size==0 condition becomes true.Whenever an error is raised from the bean handler method,it simply returns this error
The form in the jsp page where I used to make this call is also given below
<a4j:form id="searchForm"> <rich:panel id="searchCustomer"> <f:facet name="header"><h:outputText value="Search"/></f:facet> <table> <tr> <td> <h:selectOneRadio id="searchBy" value="#{customerSearch.searchBy}"> <f:selectItem itemValue="ID" itemLabel="Account ID"/> <f:selectItem itemValue="NAME" itemLabel="Customer Name" /> </h:selectOneRadio> </td> </tr> <tr> <td> <h:inputText label="Search key" required="true" id="key" value="#{customerSearch.keyword}"> </h:inputText> <rich:spacer width="5px"/> <a4j:commandButton accesskey="S" oncomplete="document.getElementById('searchForm:doSearch').disabled=false;" onclick="this.disabled=true;" onmouseover="goLite(this.form.name,this.name)" onmouseout="goDim(this.form.name,this.name)" styleClass="visionBtn" id="doSearch" value="Search" reRender="custList" action="#{customerSearch.doSearch}"/> <rich:spacer width="2px"/> <h:graphicImage id="searchHLP" style="vertical-align:middle" value="/graphics/help-icon.gif"> <rich:toolTip> <span style="white-space:nowrap"> <strong>Tip:</strong>Type '*' to get all Customers. <br/>Use<strong> ALT + S </strong>to search </span> </rich:toolTip> </h:graphicImage> </td> </tr> </table> </rich:panel> </a4j:form>
Please help me with this issue