3 Replies Latest reply on Sep 9, 2009 5:44 AM by Nick Belaevski

    suggestionbox always dies with stackOverflow error

    Ilya Dyoshin Newbie

      Good day community.

      I'm trying to implement simple SuggestionBox using richfaces. And it always dies when any data could be outputed.

      Additional problem anytime I pressKey in the textbox I'm getting 2 calls to mine autocomplete method: one with actual search string, and another with null string.

      Mine code is following:

      The Facelets template

      <?xml version='1.0' encoding='UTF-8' ?>
      
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:rich="http://richfaces.org/rich"
       xmlns:a4j="http://richfaces.org/a4j"
       >
      <head>
      </head>
      <body>
      
      <h:form>
       <h:inputText id="selectSprGeography" style="width:200;"/>
       <rich:suggestionbox height="150" width="200" for="selectSprGeography"
       usingSuggestObjects="true"
       suggestionAction="#{sprGeographyComponent.autocomplete}"
       var="result"
       fetchValue="#{result.description}"
       tokens=","
       >
       <h:column>
       <h:outputText value="#{result.fullDescription}"/>
       </h:column>
       </rich:suggestionbox>
      </h:form>
      
      </body>
      
      </html>
      
      



      And the sprGeographyComponent
      package com.uniqa.ui.components.spr.geography;
      
      import org.springframework.stereotype.Controller;
      import org.springframework.context.annotation.Scope;
      import org.springframework.beans.factory.annotation.Autowired;
      import org.slf4j.Logger;
      import org.slf4j.LoggerFactory;
      import com.uniqa.dao.intf.spr.geography.ISprGeographyDAO;
      import com.uniqa.persistence.spr.geography.SprGeography;
      
      import javax.faces.event.ValueChangeEvent;
      import java.util.List;
      import java.util.ArrayList;
      
      @Controller("sprGeographyComponent")
      @Scope("conversation.access")
      public class SprGeographyComponent {
       @Autowired
       protected ISprGeographyDAO sprGeographyDAO;
      
       Logger logger = LoggerFactory.getLogger(SprGeographyComponent.class);
      
       private List<SprGeography> currentData = new ArrayList<SprGeography>();
      
       public List<SprGeography> autocomplete(Object data) {
       String search = (String )data;
       logger.info("searching for " + search + " " + data.getClass().getCanonicalName());
      
       if (search != null) {
       //currentData = sprGeographyDAO.search(search);
       currentData = sprGeographyDAO.findByDescription(search);
       }
       return currentData;
       }
      
       public List<SprGeography> getCurrentData() {
       return currentData;
       }
      }
      
      


      Any help would be great.

      Ah yeah. I'm using Spring and MyfacesOrchestra for providing persistence between requests. (Seam seems too hard for mine development computer)

        • 1. Re: suggestionbox always dies with stackOverflow error
          Ilya Dyoshin Newbie

          And the error is the following:


          HTTP ERROR 500

          Problem accessing /lex35/test.xhtml. Reason:

          INTERNAL_SERVER_ERROR

          Caused by:

          java.lang.StackOverflowError
          at java.lang.Exception.<init>(Exception.java:77)
          at java.lang.reflect.InvocationTargetException.<init>(InvocationTargetException.java:54)
          at sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          at org.apache.commons.beanutils.PropertyUtilsBean.invokeMethod(PropertyUtilsBean.java:2155)
          at org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(PropertyUtilsBean.java:1323)
          at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:762)
          at org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtilsBean.java:837)
          at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:426)
          at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:165)
          at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:84)
          at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:165)
          at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:165)
          at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:84)
          at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:165)
          at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:165)
          at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:84)
          at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:165)
          at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:165)
          at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:84)



          • 2. Re: suggestionbox always dies with stackOverflow error
            Ilya Dyoshin Newbie

            the strange things continues.

            It begins to work If I modify mine template and remove parameter...

            usingSuggestObjects="true"




            • 3. Re: suggestionbox always dies with stackOverflow error
              Nick Belaevski Master

              Hi,

              usingSuggestObjects="true"
              leads to suggestion objects being serialized using ScriptUtils#toScript and this can fail if there are cycles in objects graph. Please check if there are any.