4 Replies Latest reply on Dec 31, 2010 3:51 AM by khalid Horri

    [org.ajax4jsf.webapp.BaseXMLFilter] - Exception in the filter chain

    khalid Horri Newbie

      Hi every one,

      what I want ?

      I have two comboBox one for hospitals and second for services in every hospital, I want to load services in the second combo when I choose one  hospital, just now things are OK

      BUT when I submit the form I get this exception ERROR [org.ajax4jsf.webapp.BaseXMLFilter] - Exception in the filter chain.

       

      the full trace :

       

      [2010-12-28 11:15:31,579] ERROR [org.ajax4jsf.webapp.BaseXMLFilter] - Exception in the filter chain
      javax.servlet.ServletException
          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
          at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
          at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
          at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174)
          at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
          at java.lang.Thread.run(Thread.java:619)
      Caused by: java.util.NoSuchElementException
          at javax.faces.component.SelectItemsIterator.next(SelectItemsIterator.java:130)
          at javax.faces.component.SelectItemsIterator.next(SelectItemsIterator.java:154)
          at javax.faces.component.SelectItemsIterator.next(SelectItemsIterator.java:61)
          at javax.faces.component.SelectUtils.matchValue(SelectUtils.java:82)
          at javax.faces.component.UISelectOne.validateValue(UISelectOne.java:144)
          at javax.faces.component.UIInput.validate(UIInput.java:875)
          at javax.faces.component.UIInput.executeValidate(UIInput.java:1072)
          at javax.faces.component.UIInput.processValidators(UIInput.java:672)
          at javax.faces.component.UIForm.processValidators(UIForm.java:234)
          at org.ajax4jsf.component.AjaxViewRoot$3.invokeContextCallback(AjaxViewRoot.java:447)
          at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:240)
          at org.ajax4jsf.component.AjaxViewRoot.processValidators(AjaxViewRoot.java:463)
          at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
          at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
          at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
          ... 25 more
      

       

      the bean:

       

      /**
       * (C) Integradis Europe 28 déc. 2010
       */
      
      package ma.integradis.vmbackoffice.gestionMedecin.ui;
      
      import java.util.ArrayList;
      import java.util.List;
      
      import ma.integradis.vmbackoffice.gestionMedecin.Hopital;
      import ma.integradis.vmbackoffice.gestionMedecin.Service;
      import ma.integradis.vmbackoffice.gestionMedecin.crud.HopitalService;
      import ma.integradis.vmbackoffice.gestionMedecin.crud.ServiceService;
      import ma.integradis.vmbackoffice.util.BaseBean;
      
      /**
       * @author KHALID
       * 
       */
      public class TestBean extends BaseBean {
      
          /**
           * 
           */
          private static final long serialVersionUID = -4150116576271693518L;
      
          private List<Hopital> hospitals;
      
          private List<Service> services;
      
          private String hospital;
      
          private String service;
      
          private ServiceService serviceService;
      
          private HopitalService hopitalService;
      
          /**
           * @return the hospitals
           */
          public List<Hopital> getHospitals() {
      
          try {
              return this.hospitals = this.hopitalService.readAll();
          } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          return this.hospitals;
          }
      
          /**
           * @param hospitals
           *            the hospitals to set
           */
          public void setHospitals(List<Hopital> hospitals) {
      
          this.hospitals = hospitals;
          }
      
          /**
           * @return the services
           */
          public List<Service> getServices() {
      
          return this.services;
          }
      
          /**
           * @param services
           *            the services to set
           */
          public void setServices(List<Service> services) {
      
          this.services = services;
          }
      
          /**
           * @return the hospital
           */
          public String getHospital() {
      
          return this.hospital;
          }
      
          /**
           * @param hospital
           *            the hospital to set
           */
          public void setHospital(String hospital) {
      
          Hopital hop;
          try {
              if (hospital != "") {
              hop = this.hopitalService.load(Integer.valueOf(hospital));
              this.services = new ArrayList<Service>(hop.getServices());
              }
          } catch (NumberFormatException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
      
          this.hospital = hospital;
          }
      
          /**
           * @return the serviceService
           */
          public ServiceService getServiceService() {
      
          return this.serviceService;
          }
      
          /**
           * @param serviceService
           *            the serviceService to set
           */
          public void setServiceService(ServiceService serviceService) {
      
          this.serviceService = serviceService;
          }
      
          /**
           * @return the hopitalService
           */
          public HopitalService getHopitalService() {
      
          return this.hopitalService;
          }
      
          /**
           * @param hopitalService
           *            the hopitalService to set
           */
          public void setHopitalService(HopitalService hopitalService) {
      
          this.hopitalService = hopitalService;
          }
      
          /**
           * @return the service
           */
          public String getService() {
      
          return this.service;
          }
      
          /**
           * @param service
           *            the service to set
           */
          public void setService(String service) {
      
          this.service = service;
          }
      
          public void save() {
      
          }
      
      }
      

       

      Test.xhtml

       

      <?xml version="1.0" encoding="ISO-8859-1" ?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition  
          xmlns="http://www.w3.org/1999/xhtml"
          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:t="http://myfaces.apache.org/tomahawk"
          xmlns:a4j="http://richfaces.org/a4j"
          xmlns:rich="http://richfaces.org/rich"
          xmlns:c="http://java.sun.com/jstl/core">
          <f:loadBundle basename="ressources.vmbackoffice" var="msg"/>
      <head>
          <title><ui:insert name="title"></ui:insert></title>
          <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
          <link href="../../styles/styles.css" rel="stylesheet" type="text/css"></link>
           
      </head>
      <body>
      
          <h:form id="vmbackoffice">
          <table>
              <tr class="bg">
                      <td class="first"><strong><h:outputText value="#{msg.hospitallabel}"/> :</strong></td>
                      <td class="last">
                         
                          <select jsfc="h:selectOneMenu"  id="hospital" value="#{testBean.hospital}"  required="false" style="width: 150px;">
                              
                              <t:selectItems value="#{testBean.hospitals}" var="hospital" itemLabel="#{hospital.designation}" itemValue="#{hospital.id}"/>
                              <a4j:support event="onchange" reRender="service" ajaxSingle="true"/>
                          </select>
                      </td>
                  </tr>
                  <tr class="bg">
                      <td class="first"><strong><h:outputText value="#{msg.servicelabel}"/> :</strong></td>
                      <td class="last">
                          <select jsfc="h:selectOneMenu"  id="service" value="#{testBean.service}"  required="false" style="width: 150px;">
                              
                              <t:selectItems value="#{testBean.services}" var="service" itemLabel="#{service.designation}" itemValue="#{service.id}"/>
                              </select>
                      </td>
                  </tr>
                  <tr>
                  <h:commandLink action="#{testBean.save}" rendered="true" ><h:outputText value="#{msg.save}"/></h:commandLink>
                  </tr>
                </table>
          </h:form>
      
      </body>
      </ui:composition>
      

       

      any help is appreciated

        • 1. Re: fill two ComboBox using a4j
          khalid Horri Newbie

          I replace

          this code :

          <h:commandLink action="#{testBean.save}" rendered="true" ><h:outputText value="#{msg.save}"/></h:commandLink>

          by

          <h:outputLink  value="javascript:void(0)" >
                      <h:outputText value="#{msg.save}"/>
                          <a4j:support event="onclick" actionListener="#{testBean.save}" ajaxSingle="true"/>
                      </h:outputLink>

          and it works fine, but I still have no explication why when I use the standard submition the exception is thrown

          1 of 1 people found this helpful
          • 2. Re: fill two ComboBox using a4j
            khalid Horri Newbie

            Now if I remove

            ajaxSingle="true"

            I get the previous error, and the parameters send via ajax are:

             

            AJAXREQUEST_viewRoot
            javax.faces.ViewStatej_id5
            vmbackoffice:hospital1
            vmbackoffice:j_id14vmbackoffice:j_id14
            vmbackoffice:service6
            vmbackoffice_SUBMIT1
            • 4. Re: [org.ajax4jsf.webapp.BaseXMLFilter] - Exception in the filter chain
              khalid Horri Newbie

              Thanks nick for yuor reply

              First the problem is not related to RF but is JSF 1.2 one, because I do the same test with JSF 2.0 and it passe w/out any exception, I thank the problem is related to the request scope, so to resolve this problem i found 3 solutions that can be helpfuls for ohters who can have the same issue.

               

              1- Use the session scope insted of request scope.

              2- In the submit button use aj4:support like this:

              <a4j:support event="onclick" actionListener="#{testBean.save}" ajaxSingle="true"/>

              you must use  ajaxSingle="true" if not you have the same problem.

               

              3- Use the component binding to load the combobox's items

              public HtmlSelectOneMenu getShtmlSelectOneMenu() {

                  if (this.shtmlSelectOneMenu == null)
                      this.shtmlSelectOneMenu = new HtmlSelectOneMenu();
                  Collection list = new ArrayList();
                  for (Service h : this.getServices()) {
                      list.add(new SelectItem(h.getId(), h.getDesignation()));
                  }
                  UISelectItems items = new UISelectItems();
                  items.setValue(list);
                  this.shtmlSelectOneMenu.getChildren().add(items);
                  return this.shtmlSelectOneMenu;
                  }

              and in the xhtml file

              <h:selectOneMenu id="service" value="#{testBean.service.id}" binding="#{testBean.shtmlSelectOneMenu}">
              </h:selectOneMenu>

              note  there's no f:selecteItems inside the selectOneMenu tag.

               

              I hope that this thread can be helpfuls for everyone.

               

              Regards

              KHaled