7 Replies Latest reply on Oct 8, 2007 7:27 AM by Daniel Kimmig

    Hibernate Search and JBoss Seam example

    Sart Valcerou Newbie

      Hello !
      I wondering can anyone post some simple examples of using Seam with Hibernate Search ?

      Best regards..

        • 1. Re: Hibernate Search and JBoss Seam example
          Pete Muir Master

          Take a look at the DVDstore example in Seam2

          • 2. Re: Hibernate Search and JBoss Seam example
            Alexander Seitz Newbie

            Hi Seam-users,

            I have a question concerning hibernate search and thought is would fit best in this thread.

            In my app I want to use a projection for a FullTextQuery to retrieve the search score of the results. What I do is the following:

            @Datamodel
            List<Object[]> searchResults;
            ...
            query = searchQuery(buildLuceneSearchString());
             query.setProjection(FullTextQuery.SCORE, FullTextQuery.THIS);
             searchResults= query.setMaxResults(pageSize + 1).setFirstResult(pageSize * currentPage).list();
            ...
            


            To output the score and persons data in the JSF I do:
            ...
            <rich:dataTable id="searchResults" rows="10" value="#{searchResults}" var="person" rendered="#{searchResults !=null and searchResults.rowCount gt 0}">
            <rich:column>
             <f:facet name="header">Score</f:facet>
             <h:outputText value="#{person[0]}" />
            </rich:column>
            <rich:column>
             <f:facet name="header">Name</f:facet>
             <h:outputText value="#{person[1].vorName}" />
            </rich:column>
            <rich:column>
             <f:facet name="header">Nachname</f:facet>
             <h:outputText value="#{person[1].nachName}" />
            </rich:column>
            ...
            


            Unfortunately this gives me an error while rendering the JSF. Is there anybody who have tried such a projection with Hibernate search and representing the results in JSF? Is the EL correct to access the data in the JSF?

            Thanks & Regards,

            Alexander

            • 3. Re: Hibernate Search and JBoss Seam example
              Pete Muir Master

              whats the error?

              • 4. Re: Hibernate Search and JBoss Seam example
                Alexander Seitz Newbie

                 

                "pete.muir@jboss.org" wrote:
                whats the error?


                The error I get is:
                (personensuche.xhtml is the template showing the results)

                Exception during request processing:
                Caused by javax.servlet.ServletException with message: "/application/personensuche.xhtml: value of context variable is not an instance of the component bound to the context variable: person"
                
                javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
                org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._invokeDoFilter(TrinidadFilterImpl.java:208)
                org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:165)
                org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:138)
                org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
                org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
                org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:44)
                org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
                org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
                org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
                org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
                org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
                org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:150)
                org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
                org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
                org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
                org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
                org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
                org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
                org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
                org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
                org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                java.lang.Thread.run(Thread.java:619)
                


                Can anybode tell me how to display elements of the object array correct?

                Thanks!

                Alexander

                • 5. Re: Hibernate Search and JBoss Seam example
                  Alexander Seitz Newbie

                  Hi,

                  sorry for asking again, but does anybody know why I am getting the error above when trying to display the searchscores with hibernate search?

                  Greetings,

                  Alexander

                  • 6. Re: Hibernate Search and JBoss Seam example
                    Daniel Kimmig Newbie

                    I was looking at your code and I am by no means an expert in Hibernate Search, but why is it necessary to have the following?


                    @Datamodel
                    List<Object[]> searchResults;



                    In your view logic you reference "person", and your error is exactly about that.


                    "/application/personensuche.xhtml: value of context variable is not an instance of the component bound to the context variable: person"
                    



                    My ignorant advice is: Try to refactor your code to get rid of that List of Object arrays. Maybe create a List by converting the search result into such a list?


                    I am sorry, I cannot help you properly, but maybe that stupid idea will help you after all.

                    • 7. Re: Hibernate Search and JBoss Seam example
                      Daniel Kimmig Newbie

                      Ooops!

                      Should have been:

                      Maybe create a Collection like List<Person> by converting the search result (assuming you have a class Person)?