1 Reply Latest reply on Dec 1, 2008 10:02 AM by Nick Belaevski

    IllegalStateException on <a4j:include/>

    vpetcu Newbie

      .Hi all,

      I'm having a problem trying to do a wizard using "a4j:include" to achieve that. Inside my main page I'm calling for the first time "site.xhtml" using "a4j:include" and it renders fine, but when I'm trying to change "viewId" , or just do a refresh, I get an "IllegalStateException".

      Any help would be appreciated :)

      Working environment: JBoss 3.2.3 GA Seam 2.0.2 SP1 Richfaces 3.2.2

      Complete StackTrace:


      javax.servlet.ServletException: org.domain.testeConverter.session.SiteConverter
       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.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
       at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
       at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
       at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
       at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       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:230)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: java.lang.IllegalStateException: org.domain.testeConverter.session.SiteConverter
       at javax.faces.component.StateHolderSaver.restore(StateHolderSaver.java:101)
       at javax.faces.component.UIComponentBase.restoreAttachedState(UIComponentBase.java:1436)
       at javax.faces.component.UIOutput.restoreState(UIOutput.java:226)
       at javax.faces.component.UIInput.restoreState(UIInput.java:1235)
       at org.richfaces.component.html.HtmlComboBox.restoreState(HtmlComboBox.java:1791)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1161)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1177)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1177)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1177)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1177)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1177)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1177)
       at org.ajax4jsf.application.AjaxStateManager.restoreView(AjaxStateManager.java:415)
       at com.sun.faces.application.ViewHandlerImpl.restoreView(ViewHandlerImpl.java:316)
       at org.jboss.seam.jsf.SeamViewHandler.restoreView(SeamViewHandler.java:93)
       at org.ajax4jsf.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:116)
       at com.sun.facelets.FaceletViewHandler.restoreView(FaceletViewHandler.java:316)
       at org.ajax4jsf.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:116)
       at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:176)
       at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
       at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:104)
       at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
       ... 39 more
      15:00:40,312 ERROR [ExceptionFilter] exception root cause
      java.lang.IllegalStateException: org.domain.testeConverter.session.SiteConverter
       at javax.faces.component.StateHolderSaver.restore(StateHolderSaver.java:101)
       at javax.faces.component.UIComponentBase.restoreAttachedState(UIComponentBase.java:1436)
       at javax.faces.component.UIOutput.restoreState(UIOutput.java:226)
       at javax.faces.component.UIInput.restoreState(UIInput.java:1235)
       at org.richfaces.component.html.HtmlComboBox.restoreState(HtmlComboBox.java:1791)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1161)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1177)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1177)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1177)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1177)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1177)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1177)
       at org.ajax4jsf.application.AjaxStateManager.restoreView(AjaxStateManager.java:415)
       at com.sun.faces.application.ViewHandlerImpl.restoreView(ViewHandlerImpl.java:316)
       at org.jboss.seam.jsf.SeamViewHandler.restoreView(SeamViewHandler.java:93)
       at org.ajax4jsf.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:116)
       at com.sun.facelets.FaceletViewHandler.restoreView(FaceletViewHandler.java:316)
       at org.ajax4jsf.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:116)
       at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:176)
       at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
       at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:104)
       at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
       at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
       at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
       at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
       at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       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:230)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Thread.java:595)
      


      my code:

      WizardBean.java

      package org.domain.testeConverter.session;
      
      import static org.jboss.seam.ScopeType.CONVERSATION;
      
      import javax.faces.event.ActionEvent;
      
      import org.jboss.seam.annotations.Begin;
      import org.jboss.seam.annotations.End;
      import org.jboss.seam.annotations.Logger;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.log.Log;
      
      @Scope(CONVERSATION)
      @Name("wizard")
      public class WizardBean {
      
       @Logger
       private Log log;
      
       private String step = "/site.xhtml";
      
       private int site_id;
      
       private int category_id;
      
       private int structure_id;
      
       public String getStep() {
       return step;
       }
      
       public void setStep(String step) {
       this.step = step;
       }
      
       public int getSite_id() {
       return site_id;
       }
      
       public void setSite_id(int site_id) {
       this.site_id = site_id;
       }
      
       public int getCategory_id() {
       return category_id;
       }
      
       public void setCategory_id(int category_id) {
       this.category_id = category_id;
       }
      
       public int getStructure_id() {
       return structure_id;
       }
      
       public void setStructure_id(int structure_id) {
       this.structure_id = structure_id;
       }
      
       @Begin
       public String begin() {
       // implement your begin conversation business logic
       log.info("beginning conversation");
       return "success";
       }
      
      
       // add additional action methods that participate in this conversation
      
       @End
       public String end() {
       // implement your end conversation business logic
       log.info("ending conversation");
       return "home";
       }
      
       public void changePage(ActionEvent event){
       }
      
      
      }
      


      SiteConverter.java:

      package org.domain.testeConverter.session;
      
      import javax.faces.component.UIComponent;
      import javax.faces.context.FacesContext;
      import javax.faces.convert.ConverterException;
      import javax.persistence.EntityManager;
      
      import org.domain.publishing.entity.Site;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Transactional;
      import org.jboss.seam.annotations.faces.Converter;
      import org.jboss.seam.annotations.intercept.BypassInterceptors;
      
      @Name("siteConverter")
      @BypassInterceptors
      @Converter(forClass = Site.class)
      public class SiteConverter implements javax.faces.convert.Converter {
      
       @In(create = true)
       private EntityManager entityManager;
      
       @Transactional
       public Object getAsObject(FacesContext context, UIComponent component,
       String value) throws ConverterException {
       String id=value;
       if(id!=null)
       return entityManager.find(Site.class, id);
       return null;
       }
      
       public String getAsString(FacesContext context, UIComponent component,
       Object value) throws ConverterException {
       if(value instanceof Site){
       Site site=(Site) value;
       return "" + site.getName();
       }
       else return null;
       }
      }
      


      wizardBegining.xhtml:

      <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:s="http://jboss.com/products/seam/taglib"
       xmlns:a4j="http://richfaces.org/a4j"
       xmlns:rich="http://richfaces.org/rich" template="layout/template.xhtml">
      
       <ui:define name="body">
       <style type="text/css">
      .col1 {
       vertical-align: top;
      }
      
      .col2 {
       vertical-align: top;
       width: 450px;
      }
      
      .wizardMenu {
       width: 100px;
      }
      
      .wizard {
       width: 400px;
       float: left;
      }
      
      .wform td {
       vertical-align: top;
      }
      
      .wfcol1 {
       text-align: right;
       white-space: nowrap;
      }
      
      .wfcol2 {
      
      }
      
      .wfcol3 {
      
      }
      
      .s1row td {
       height: 30px;
      }
      
      .rich-message {
       color: red;
      }
      
      .navPanel {
       position: absolute;
       bottom: 0;
       height: 23px;
       margin: 0;
       padding: 2px;
      }
      </style>
       <br />
       <h:panelGrid width="500px" columns="2" columnClasses="col1,col2">
       <rich:panel styleClass="wizardMenu">
       <f:facet name="header">
       <h:outputText value="Steps" />
       </f:facet>
       <ui:include src="layout/wizardMenu.xhtml" />
       </rich:panel>
       <rich:panel styleClass="wizard">
       <f:facet name="header">
       <h:outputText value="Create new template" />
       </f:facet>
       <h:form>
       <a4j:include id="wizardBody" viewId="#{wizard.step}" />
       </h:form>
       </rich:panel>
      
       </h:panelGrid>
       <br />
       </ui:define>
      </ui:composition>
      


      wizardMenu.xhtml:

      <html
       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:s="http://jboss.com/products/seam/taglib"
       xmlns:a4j="http://richfaces.org/a4j"
       xmlns:rich="http://richfaces.org/rich">
      <body>
       <div style="position:relative;height:140px;">
       <a4j:form>
       <a4j:commandLink reRender="wizardBody" actionListener="#{wizard.changePage}">
       <a4j:actionparam assignTo="#{wizard.step}" name="step" value="/site.xhtml">
       </a4j:actionparam>
       <h:outputText value="Site" />
       </a4j:commandLink><br /><br />
       <a4j:commandLink reRender="wizardBody" actionListener="#{wizard.changePage}">
       <a4j:actionparam assignTo="#{wizard.step}" name="step" value="/category.xhtml">
       </a4j:actionparam>
       <h:outputText value="Category" />
       </a4j:commandLink><br /><br />
       <a4j:commandLink reRender="wizardBody" actionListener="#{wizard.changePage}">
       <a4j:actionparam assignTo="#{wizard.step}" name="step" value="/template.xhtml">
       </a4j:actionparam>
       <h:outputText value="Template" />
       </a4j:commandLink><br /><br />
       </a4j:form>
       </div>
      </body>
      </html>
      


      site.xhtml:

      <html 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:s="http://jboss.com/products/seam/taglib"
       xmlns:a4j="http://richfaces.org/a4j"
       xmlns:rich="http://richfaces.org/rich">
      
       <div style="position:relative;height:140px;">
       <h:panelGrid rowClasses="s1row" columns="2" columnClasses="wfcol1,wfcol2,wfcol3" id="wizardBody">
       <rich:comboBox selectFirstOnUpdate="false"
       defaultLabel="Choose site" converter="siteConverter" suggestionValues="#{siteList.resultList}">
       </rich:comboBox>
      
       bla
       </h:panelGrid>
       <div class="navPanel">
       <a4j:commandButton style="float:right" action="next" value="Next >>"/>
       </div>
       </div>
      </html>