2 Replies Latest reply on Oct 26, 2007 9:48 AM by epbernard

    Help!!! Seam with Hibernate Search problem

      Help!!!

      I use seam1.2.1 and Hibernate Search3.0GA .The server is GlassfishV2.

      I have saw the FullTextSession source code. And the "createFullTextQuery"
      method is exactly exist.


      Caused by: java.lang.NoSuchMethodError: org.hibernate.search.FullTextSession.createFullTextQuery(Lorg/apache/lucene/search/Query;[Ljava/lang/Class;)Lorg/hibernate/search/FullTextQuery;
      at org.hibernate.search.jpa.impl.FullTextEntityManagerImpl.createFullTextQuery(FullTextEntityManagerImpl.java:61)
      at com.feelingmobile.mobilestore.session.SearchBean.searchQuery(SearchBean.java:148)
      at com.feelingmobile.mobilestore.session.SearchBean.updateResults(SearchBean.java:158)
      at com.feelingmobile.mobilestore.session.SearchBean.doSearch(SearchBean.java:84)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1067)
      at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:176)
      at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4005)
      at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:483)
      at com.sun.ejb.Invocation.proceed(Invocation.java:498)
      ... 95 more

        • 1. Re: Help!!! Seam with Hibernate Search problem

          Here is the source code.

          /**
          *
          * @author lv.jianping
          */
          @Stateful
          @Name(value = "search")
          public class SearchBean implements SearchLocal, Serializable {

          @PersistenceContext
          private EntityManager em;
          int pageSize = 15;
          int currentPage = 0;
          boolean hasMore = false;
          int resultsNumber = 0;
          String searchQuery;
          @DataModel
          List searchResults;
          @DataModelSelection
          @Out(required = false)
          Content selectedContent;

          public Content getSelectedContent() {
          return selectedContent;
          }

          public void getSearchResults() {
          doSearch();
          }


          public String getSearchQuery() {
          return searchQuery;
          }

          public void setSearchQuery(String searchQuery) {
          this.searchQuery = searchQuery;
          }

          public int getResultsNumber() {
          return resultsNumber;
          }

          public String doSearch() {
          currentPage = 0;
          updateResults();
          return "searchResults";
          }

          public void doIndex() {
          FullTextEntityManager ftEm = Search.createFullTextEntityManager(em);
          List contents = em.createQuery("select c from Content c where c.isdeleted='0' and c.contentstate='1' ").getResultList();

          for (Object object : contents){
          ftEm.index((Content)object);
          }
          }

          public void nextPage() {
          if (!isLastPage()) {
          currentPage++;
          updateResults();
          }
          }

          public void prePage() {
          if (!isFirstPage()) {
          currentPage--;
          updateResults();
          }
          }

          public boolean isLastPage() {
          return (searchResults != null) && !hasMore;
          }

          public boolean isFirstPage() {
          return (searchResults != null) && (currentPage == 0);
          }

          public int getPageSize() {
          return pageSize;
          }

          public void setPageSize(int pageSize) {
          this.pageSize = 10;
          }

          private javax.persistence.Query searchQuery(String searchQuery) throws ParseException {
          Map<String, Float> boostPerField = new HashMap<String, Float>();
          boostPerField.put("contenttitle", 4f);
          boostPerField.put("contentbody", 2f);
          boostPerField.put("contentbodysms", 2f);
          String[] contentFields = {"contenttitle", "contentbody", "contentbodysms"};
          QueryParser parser = new MultiFieldQueryParser(contentFields, new StandardAnalyzer(), boostPerField);
          parser.setAllowLeadingWildcard(true);
          org.apache.lucene.search.Query luceneQuery = parser.parse(searchQuery);
          FullTextEntityManager ftEm = Search.createFullTextEntityManager(em);

          //********Here Exception is throwed out*************//
          javax.persistence.Query query = ftEm.createFullTextQuery(luceneQuery, Content.class);
          return query;

          }

          private void updateResults() {
          Query query;
          try {
          query = searchQuery(searchQuery);
          } catch (ParseException pe) {
          return;
          }

          @SuppressWarnings(value = "unchecked")
          List items = query.setMaxResults(pageSize + 1).setFirstResult(pageSize * currentPage).getResultList();
          resultsNumber = items.size();

          if (items.size() > pageSize) {
          searchResults = new ArrayList(items.subList(0, pageSize));
          hasMore = true;
          } else {
          searchResults = items;
          hasMore = false;
          }
          }


          @Destroy
          @Remove
          public void destroy() {
          }
          }

          • 2. Re: Help!!! Seam with Hibernate Search problem
            epbernard

            You need to be sure to have hibernate annotations 3.3.0 and Hibernate 3.0.0 in your classpath, and not older versions.