1 Reply Latest reply on Feb 26, 2007 9:19 PM by Pete Muir

    selectItems / Converter Issue

    Dave Everson Newbie

      We are in the process of implementing a converter for a drop-down list in our application.

      We are using Seam 1.1.7 RC1, JBoss 4.0.5, facelets, and ajax4jsf.

      The page with the drop down is being executed as part of a page flow.

      The page is properly displaying the drop down list values (the first name of resources to assign the work task to).
      Whenever the user selects a value from the drop down list and clicks on the next button, the following stack trace is generated:

      2007-02-26 19:55:16,689 ERROR [org.jboss.seam.web.ExceptionFilter] uncaught exception
      javax.servlet.ServletException: Could not restore StateHolder of type us.crimnet.iss.view.converters.Converters$1 (missing no-args constructor?)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:152)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
       at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:67)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:223)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      2007-02-26 19:55:16,689 ERROR [org.jboss.seam.web.ExceptionFilter] exception root cause
      java.lang.RuntimeException: Could not restore StateHolder of type us.crimnet.iss.view.converters.Converters$1 (missing no-args constructor?)
       at javax.faces.component.UIComponentBase.restoreAttachedState(UIComponentBase.java:894)
       at org.jboss.seam.ui.PrioritizableConverter.restoreState(PrioritizableConverter.java:85)
       at javax.faces.component.UIComponentBase.restoreAttachedState(UIComponentBase.java:903)
       at javax.faces.component.UIComponentBase.restoreAttachedState(UIComponentBase.java:880)
       at org.jboss.seam.ui.ConverterChain.restoreState(ConverterChain.java:187)
       at javax.faces.component.UIComponentBase.restoreAttachedState(UIComponentBase.java:903)
       at javax.faces.component.UIOutput.restoreState(UIOutput.java:94)
       at javax.faces.component.UIInput.restoreState(UIInput.java:489)
       at javax.faces.component.html.HtmlSelectOneMenu.restoreState(HtmlSelectOneMenu.java:408)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:728)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:719)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:719)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:719)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:719)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:719)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:719)
       at org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreComponentState(JspStateManagerImpl.java:221)
       at org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreView(JspStateManagerImpl.java:287)
       at org.ajax4jsf.framework.ajax.AjaxStateManager.restoreView(AjaxStateManager.java:76)
       at org.jboss.seam.jsf.SeamStateManager.restoreView(SeamStateManager.java:97)
       at org.ajax4jsf.framework.ajax.AjaxStateManager.restoreView(AjaxStateManager.java:76)
       at org.apache.myfaces.application.jsp.JspViewHandlerImpl.restoreView(JspViewHandlerImpl.java:255)
       at com.sun.facelets.FaceletViewHandler.restoreView(FaceletViewHandler.java:353)
       at org.ajax4jsf.framework.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:109)
       at org.ajax4jsf.framework.ajax.AjaxViewHandler.restoreView(AjaxViewHandler.java:135)
       at org.jboss.seam.jsf.SeamViewHandler.restoreView(SeamViewHandler.java:127)
       at com.sun.facelets.FaceletViewHandler.restoreView(FaceletViewHandler.java:353)
       at org.ajax4jsf.framework.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:109)
       at org.ajax4jsf.framework.ajax.AjaxViewHandler.restoreView(AjaxViewHandler.java:135)
       at org.apache.myfaces.lifecycle.LifecycleImpl.restoreView(LifecycleImpl.java:141)
       at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:66)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
      Caused by: java.lang.InstantiationException: us.crimnet.iss.view.converters.Converters$1
       at java.lang.Class.newInstance0(Class.java:335)
       at java.lang.Class.newInstance(Class.java:303)
       at javax.faces.component.UIComponentBase.restoreAttachedState(UIComponentBase.java:890)
       at org.jboss.seam.ui.PrioritizableConverter.restoreState(PrioritizableConverter.java:85)
       at javax.faces.component.UIComponentBase.restoreAttachedState(UIComponentBase.java:903)
       at javax.faces.component.UIComponentBase.restoreAttachedState(UIComponentBase.java:880)
       at org.jboss.seam.ui.ConverterChain.restoreState(ConverterChain.java:187)
       at javax.faces.component.UIComponentBase.restoreAttachedState(UIComponentBase.java:903)
       at javax.faces.component.UIOutput.restoreState(UIOutput.java:94)
       at javax.faces.component.UIInput.restoreState(UIInput.java:489)
       at javax.faces.component.html.HtmlSelectOneMenu.restoreState(HtmlSelectOneMenu.java:408)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:728)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:719)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:719)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:719)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:719)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:719)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:719)
       at org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreComponentState(JspStateManagerImpl.java:221)
       at org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreView(JspStateManagerImpl.java:287)
       at org.ajax4jsf.framework.ajax.AjaxStateManager.restoreView(AjaxStateManager.java:76)
       at org.jboss.seam.jsf.SeamStateManager.restoreView(SeamStateManager.java:97)
       at org.ajax4jsf.framework.ajax.AjaxStateManager.restoreView(AjaxStateManager.java:76)
       at org.apache.myfaces.application.jsp.JspViewHandlerImpl.restoreView(JspViewHandlerImpl.java:255)
       at com.sun.facelets.FaceletViewHandler.restoreView(FaceletViewHandler.java:353)
       at org.ajax4jsf.framework.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:109)
       at org.ajax4jsf.framework.ajax.AjaxViewHandler.restoreView(AjaxViewHandler.java:135)
       at org.jboss.seam.jsf.SeamViewHandler.restoreView(SeamViewHandler.java:127)
       at com.sun.facelets.FaceletViewHandler.restoreView(FaceletViewHandler.java:353)
       at org.ajax4jsf.framework.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:109)
       at org.ajax4jsf.framework.ajax.AjaxViewHandler.restoreView(AjaxViewHandler.java:135)
       at org.apache.myfaces.lifecycle.LifecycleImpl.restoreView(LifecycleImpl.java:141)
      2007-02-26 19:55:16,799 INFO [org.jboss.seam.core.Exceptions] reading exception mappings from /WEB-INF/pages.xml
      2007-02-26 19:55:16,819 ERROR [org.jboss.seam.exceptions.DebugPageHandler] redirecting to debug page
      ...
      


      Our converter code looks like:
      package us.crimnet.iss.view.converters;
      
      import javax.faces.component.UIComponent;
      import javax.faces.context.FacesContext;
      import javax.faces.convert.Converter;
      import javax.faces.convert.ConverterException;
      
      import org.jboss.seam.Component;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Transactional;
      
      import us.crimnet.iss.services.ProfileManagement;
      import us.crimnet.iss.services.impl.ProfileManagementImpl;
      import us.crimnet.iss.om.core.Person;
      
      @Name("converters")
      public class Converters {
      
       @Transactional
       public Converter getPersonConverter() {
       return new Converter() {
      
       @Transactional
       public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) throws ConverterException {
       System.out.println("getAsObject [" + arg2 + "]");
       if (arg2 == null) {
       return null;
       }
       try {
       ProfileManagement profileManagement =
       (ProfileManagement)
       Component.getInstance(ProfileManagementImpl.class);
       return profileManagement.getPersonByPK(Long.valueOf(arg2));
       } catch (NumberFormatException e) {
       throw new ConverterException("Cannot find selected Person", e);
       }
       }
      
       @Transactional
       public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) throws ConverterException {
       System.out.println("getAsString [" + arg2 + "]");
       if (arg2 instanceof Person) {
       Person person = (Person) arg2;
       return person.getId().toString();
       } else {
       return null;
       }
       }
       };
       }
      }
      


      snippet of the facelets xhtml:
       <h:column>
       <f:facet name="header">
       <h:outputText value="Owner" />
       </f:facet>
       <h:selectOneMenu value="#{request.owner}"
       converter="#{converters.personConverter}"
       required="false">
       <s:selectItems value="#{wizard.resources}" var="person" label="#{person.firstName}"
       noSelectionLabel="Please Select..." hideNoSelectionLabel="true" />
       </h:selectOneMenu>
       </h:column>
      


      We are using the ui example as a pattern. In fact, the ui example is successfully run in our environment.

      Any suggestions as to what is causing the issue/stack trace?

      Thanks!