9 Replies Latest reply on Dec 21, 2008 1:32 PM by chris.simons

    rich:suggestionBox: StackOverflowError

    j-pro

      Good afternoon, dear RichFaces gurus!

      Today I've found(thanks to Ilya) great component - rich:suggestionbox. I've change second live-demo example to work with my objects, wrote my bean, etc, but it doesn't work. When I enter a letter, it gives me this exception: http://pastebin.com/f4a1185c1

      When I enter wrong letter, it gives me a popup with "Empty" word, so when the list contains no elements, it works.

      My jsf:

      <h:panelGroup>
       <h:panelGrid columns="2" border="0" cellpadding="0" cellspacing="0">
       <h:inputText id="employeeProfessionEdit"/>
       <h:graphicImage value="/images/arrow4select.png" onclick="#{rich:component('professionSuggestion')}.callSuggestion(true)"/>
       </h:panelGrid>
       <rich:suggestionbox id="professionSuggestion" for="employeeProfessionEdit" suggestionAction="#{allTreeListMan.autoCompleteAllTree}"
       fetchValue="#{profession.name}" height="200" width="200" usingSuggestObjects="true" var="profession"
       status="#{constMan.unknownStatusComponentID}" nothingLabel="Empty">
       <a4j:support event="onselect" reRender="applicantsDataTableForm_OutputPanel"/>
       <h:column>
       <h:outputText value="#{profession.name}"/>
       </h:column>
       </rich:suggestionbox>
      </h:panelGroup>


      The objects list which is returned by allTreeListMan.autoCompleteAllTree consists of some fields(some primitive types, some - Lists of another objects). Its overrided toString() method returns a string with only primitive types in it, divided with a separator like "$#%%$#" for example.
      This method(autoCompleteAllTree) works fine, I see it from my logs - the array is returned. (Btw, I don't understand, why the method is invoked twice - first time it returns list of 5 objects, the second - empty list. But it's not the reason of the subject, I think, isn't it?)

      What happens?

      Thanks in advance!

      P.S.: JSF 1.2_07-b03-FCS
      facelets-1.1.14
      jboss-4.2.3.GA with jdk1.5.0_09
      Firefox 2.0.0.17

        • 1. Re: rich:suggestionBox: StackOverflowError
          nbelaevski

          Hello,

          This exception happens because our JavaScript serializer fails with JavaScript object containing cycled references, here is the issue for that: https://jira.jboss.org/jira/browse/RF-4903. I'd recommend to switch off "usingSuggestObjects" if you're not planning to use this feature.

          • 2. Re: rich:suggestionBox: StackOverflowError
            nbelaevski

            ... or break cycled references in server objects used as suggestion box data if possible.

            • 3. Re: rich:suggestionBox: StackOverflowError
              j-pro

               

              "nbelaevski" wrote:
              This exception happens because our JavaScript serializer fails with JavaScript object containing cycled references


              If I understood you right, "cycled references" - is if a class has reference instance variable, referencing on the same class instance. Right? So, I've changed my allTreeListMan.autoCompleteAllTree() method to return not list of these objects containing cycled references, but simple SelectItem objects(contains value and label). Have the same exception...

              If I turn off "usingSuggestObjects" - everything works fine. So the reason isn't cycling references?

              • 4. Re: rich:suggestionBox: StackOverflowError
                j-pro

                One more question, If you don't mind...

                Going back to old autoCompleteAllTree() method, returning a List of these "big" objects(containing cycled references), if I turn "usingSuggestObjects" off, can I make this(considering that bean.myAllTree is of type of this "big" class and I have converter class for it):

                <h:panelGroup>
                 <h:panelGrid columns="2" border="0" cellpadding="0" cellspacing="0">
                 <h:inputText id="employeeProfessionEdit"/>
                 <h:graphicImage value="/images/arrow4select.png" onclick="#{rich:component('professionSuggestion')}.callSuggestion(true)"/>
                 </h:panelGrid>
                 <rich:suggestionbox id="professionSuggestion" for="employeeProfessionEdit" suggestionAction="#{allTreeListMan.autoCompleteAllTree}"
                 fetchValue="#{profession.name}" height="200" width="200" var="profession"
                 status="#{constMan.unknownStatusComponentID}" nothingLabel="#{muiBundle.suggestionNoVariants}">
                 <a4j:support event="onselect" reRender="applicantsDataTableForm_OutputPanel">
                 <a4j:actionparam value="#{profession}" name="param" assignTo="#{bean.myAllTree}" />
                 </a4j:support>
                 <h:column>
                 <h:outputText value="#{profession.name}"/>
                 </h:column>
                 </rich:suggestionbox>
                </h:panelGroup>



                Thank you for the reply.

                • 5. Re: rich:suggestionBox: StackOverflowError
                  nbelaevski

                  Hi,

                  Works fine for me using SelectItem objects. Just to clarify: do you mean javax.faces.model.SelectItem or another one? Can you please provide information what label, description and value are used?

                  No, that won't work. Use:

                  <a4j:support event="onselect">
                   <f:setPropertyActionListener value="#{result}" target="#{forum5Bean.o1}" />
                   </a4j:support>
                  
                  instead.

                  • 6. Re: rich:suggestionBox: StackOverflowError
                    j-pro

                     

                    "nbelaevski" wrote:
                    Works fine for me using SelectItem objects. Just to clarify: do you mean javax.faces.model.SelectItem or another one? Can you please provide information what label, description and value are used?
                    Ooops, sorry. I've forgot that the "value" attribute of my SelectItem object is actually that "big" object which contain cycled reference. Sorry, it should have been worked if it was variable of primitive type.

                    "nbelaevski" wrote:
                    No, that won't work. Use:
                    <a4j:support event="onselect">
                     <f:setPropertyActionListener value="#{result}" target="#{forum5Bean.o1}" />
                     </a4j:support>
                    
                    instead.
                    Hm... thank you very much, that works!

                    Thank you again, Nick, very much for your help!


                    P.S.: Can't you please tell me, why using a4j:actionparam and having appropriate converter, it still wasn't working? I mean, for example, having this code:
                    <a4j:actionparam value="#{profession.intNumber}" name="param" assignTo="#{bean.myInteger}" />

                    and considering that parameter is of type Integer, there was an exception:
                    2008-11-11 18:39:56,343 DEBUG [org.ajax4jsf.event.AjaxPhaseListener] Process before phase INVOKE_APPLICATION 5
                    2008-11-11 18:39:56,343 DEBUG [javax.enterprise.resource.webcontainer.jsf.lifecycle] Entering InvokeApplicationsPhase
                    2008-11-11 18:39:56,343 DEBUG [javax.enterprise.resource.webcontainer.jsf.application] Created converter of type 'javax.faces.convert.IntegerConverter'
                    2008-11-11 18:39:56,375 WARN [javax.enterprise.resource.webcontainer.jsf.lifecycle] applicantsDataTable_Form:professionSuggestion:j_id216: 'null' must be a number consisting of one or more digits.
                    javax.faces.convert.ConverterException: applicantsDataTable_Form:professionSuggestion:j_id216: 'null' must be a number consisting of one or more digits.
                     at javax.faces.convert.IntegerConverter.getAsObject(IntegerConverter.java:118)
                     at org.ajax4jsf.component.UIActionParameter.processAction(UIActionParameter.java:168)
                     at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
                     at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:760)
                     at javax.faces.component.UICommand.broadcast(UICommand.java:372)
                     at org.ajax4jsf.component.AjaxActionComponent.broadcast(AjaxActionComponent.java:55)
                     at javax.faces.component.UIData.broadcast(UIData.java:926)
                     at org.richfaces.component.UISuggestionBox.broadcast(UISuggestionBox.java:421)
                     at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:321)
                     at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:296)
                     at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:253)
                     at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:466)
                     at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
                     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)
                     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                     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.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:182)
                     at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                     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:262)
                     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
                     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
                     at java.lang.Thread.run(Thread.java:595)
                    2008-11-11 18:39:56,375 ERROR [javax.enterprise.resource.webcontainer.jsf.lifecycle] JSF1054: (Phase ID: INVOKE_APPLICATION 5, View ID: /applicants.xhtml) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@4373ea]
                    2008-11-11 18:39:56,375 DEBUG [org.ajax4jsf.event.AjaxPhaseListener] Process after phase INVOKE_APPLICATION 5
                    2008-11-11 18:39:56,375 DEBUG [javax.enterprise.resource.webcontainer.jsf.timing] [TIMING] - [32ms] : Execution time for phase (including any PhaseListeners) -> INVOKE_APPLICATION 5
                    2008-11-11 18:39:56,375 ERROR [org.ajax4jsf.webapp.BaseXMLFilter] Exception in the filter chain
                    javax.servlet.ServletException: applicantsDataTable_Form:professionSuggestion:j_id216: 'null' must be a number consisting of one or more digits.
                     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.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.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:182)
                     at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                     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:262)
                     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
                     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
                     at java.lang.Thread.run(Thread.java:595)
                    Caused by: javax.faces.convert.ConverterException: applicantsDataTable_Form:professionSuggestion:j_id216: 'null' must be a number consisting of one or more digits.
                     at javax.faces.convert.IntegerConverter.getAsObject(IntegerConverter.java:118)
                     at org.ajax4jsf.component.UIActionParameter.processAction(UIActionParameter.java:168)
                     at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
                     at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:760)
                     at javax.faces.component.UICommand.broadcast(UICommand.java:372)
                     at org.ajax4jsf.component.AjaxActionComponent.broadcast(AjaxActionComponent.java:55)
                     at javax.faces.component.UIData.broadcast(UIData.java:926)
                     at org.richfaces.component.UISuggestionBox.broadcast(UISuggestionBox.java:421)
                     at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:321)
                     at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:296)
                     at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:253)
                     at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:466)
                     at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
                     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)
                     ... 24 more
                    2008-11-11 18:39:56,390 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/AHRS].[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
                    javax.faces.convert.ConverterException: applicantsDataTable_Form:professionSuggestion:j_id216: 'null' must be a number consisting of one or more digits.
                     at javax.faces.convert.IntegerConverter.getAsObject(IntegerConverter.java:118)
                     at org.ajax4jsf.component.UIActionParameter.processAction(UIActionParameter.java:168)
                     at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
                     at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:760)
                     at javax.faces.component.UICommand.broadcast(UICommand.java:372)
                     at org.ajax4jsf.component.AjaxActionComponent.broadcast(AjaxActionComponent.java:55)
                     at javax.faces.component.UIData.broadcast(UIData.java:926)
                     at org.richfaces.component.UISuggestionBox.broadcast(UISuggestionBox.java:421)
                     at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:321)
                     at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:296)
                     at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:253)
                     at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:466)
                     at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
                     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)
                     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                     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.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:182)
                     at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                     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:262)
                     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
                     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
                     at java.lang.Thread.run(Thread.java:595)

                    So why there is null instead of a string to convert?

                    • 7. Re: rich:suggestionBox: StackOverflowError
                      nbelaevski

                      Because <a4j:support> is output once. If it is output for every item then this code will work. You can try to use:

                      <a4j:actionparam value="suggestion.getCurrentEntry().rowIndex" noEscape="true" name="param" assignTo="#{bean.myAllTree}" />
                      


                      • 8. Re: rich:suggestionBox: StackOverflowError
                        j-pro

                        Thank you very much, Nick!

                        • 9. Re: rich:suggestionBox: StackOverflowError

                          Nick and J-Pro,

                          This thread helped me figure out why usingSuggestObjects="true" was not working.

                          Now, I'm trying to implement the f:setActionPropertyListener approach to take the selected object and set it to my conversational entity bean (Seam 2.1.SP1).

                          However, I'm receiving conversion errors, such as:
                          Conversion Error setting value 'Administrator' for 'null Converter'.

                          Googling the issue, it would appear that I need to build a converter to take my selected object and return it as an object. But, if so, how come I don't have to do this for other selectItems wherein I set the value directly to that of an object? Here is my rich:suggestionBox if anyone would like to help me figure out whether I need to make a converter. Thank you.

                          Note: In the code below, {result} is a User object. {result.userProfile} is another object, "UserProfile", which is a child of Object.

                          {cvEventContact.contact } is of type UserProfile. So there should be no object mismatch going on.

                          <h:inputText id="contact" value="#{cvEventContact.contact}"
                           required="true" autocomplete="true"/>
                           <rich:suggestionbox id="userPicker"
                           minChars="4"
                           for="contact"
                           tokens=",[]"
                           suggestionAction="#{userPicker.getAllUsersByInput}"
                           var="result"
                           usingSuggestObjects="false"
                           nothingLabel="#{messages['suggestions.nothingLabel']}"
                           width="#{globals['output.suggestionBox.width']}"
                           status="userPickerStatus">
                           <a4j:support event="onselect">
                           <f:setPropertyActionListener value="#{result.userProfile}" target="#{cvEventContact.contact}" />
                           </a4j:support>
                           <h:column>
                           <h:outputText value="#{result.fullName}"/>
                           </h:column>
                           <h:column>
                           <h:outputText value="#{result.userId}"/>
                           </h:column>
                           <h:column>
                           <h:outputText value="[#{result.primaryOrg.shortName}]"/>
                           </h:column>
                           </rich:suggestionbox>