-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: [Solved] Problems with Hibernate search + web project
PostPosted: Thu Jun 18, 2009 10:01 am 
Newbie

Joined: Thu Jun 18, 2009 9:39 am
Posts: 2
Hi,
I´m using hibernate search in a simple project(standalone) and it works fine.
Now i´m trying to use it on a web project(richfaces + tomcat). I´m using the same class of the standalone project but does not work.

The "indexBase" property is configured like this
Code:
   <property name="hibernate.search.default.indexBase">
        ../webapps/JBancoTalentos/WEB-INF/indices
    </property>


in the standalone project, "indexBase" was configured like this
Code:
   <property name="hibernate.search.default.indexBase">
        c:\_indexes
    </property>


// execute the search
Code:
   @SuppressWarnings("unchecked")
   private List<Curriculo> pesquisar(String[] campos, String strQuery) {      

      luceneSession = Search.createFullTextSession(session);
      MultiFieldQueryParser parser = new MultiFieldQueryParser(campos, new StandardAnalyzer());

      try {
         luceneQuery = parser.parse(strQuery);
      } catch (ParseException e) {
         e.printStackTrace();
      }
      fullTextQuery = luceneSession.createFullTextQuery(luceneQuery, Curriculo.class);
      System.out.println(fullTextQuery.toString());
      List<Curriculo> lista = new ArrayList<Curriculo>();
      try {
         lista = fullTextQuery.list(); // * E R R O R *
      } catch (Exception ex) {
         ex.getMessage();
         ex.printStackTrace();
      }
      return lista;
   }


the full stack trace
Code:
java.lang.NullPointerException
   at org.hibernate.search.util.ContextHelper.getSearchFactoryBySFI(ContextHelper.java:23)
   at org.hibernate.search.query.FullTextQueryImpl.list(FullTextQueryImpl.java:228)
   at br.com.gtcon.jbancotalentos.jsf.managedbeans.admin.BuscaCurriculo.pesquisar(BuscaCurriculo.java:90)
   at br.com.gtcon.jbancotalentos.jsf.managedbeans.admin.BuscaCurriculo.montarQuery(BuscaCurriculo.java:244)
   at br.com.gtcon.jbancotalentos.jsf.managedbeans.admin.BuscaCurriculo.buscar(BuscaCurriculo.java:111)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.apache.el.parser.AstValue.invoke(AstValue.java:172)
   at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
   at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
   at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:71)
   at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:95)
   at javax.faces.component.UICommand.broadcast(UICommand.java:384)
   at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:317)
   at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:292)
   at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:249)
   at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:462)
   at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
   at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:266)
   at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:132)
   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
   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:154)
   at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:260)
   at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:366)
   at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:493)
   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:233)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
   at java.lang.Thread.run(Unknown Source)
FullTextQueryImpl(minicurriculo:computação outrasNecessidadesEspeciais:computação experienciasProfissionais.descricao:computação experienciasProfissionais.empresa:computação experienciasProfissionais.cargo:computação habilidade.descricao:computação habilidadesNaoCadastradas.habilidadeNaoCadastrada:computação certificacoes.descricao:computação formacoesAcademicas.instituicao:computação formacoesAcademicas.curso:computação minicurriculo:informação outrasNecessidadesEspeciais:informação experienciasProfissionais.descricao:informação experienciasProfissionais.empresa:informação experienciasProfissionais.cargo:informação habilidade.descricao:informação habilidadesNaoCadastradas.habilidadeNaoCadastrada:informação certificacoes.descricao:informação formacoesAcademicas.instituicao:informação formacoesAcademicas.curso:informação)
java.lang.NullPointerException
   at org.hibernate.search.util.ContextHelper.getSearchFactoryBySFI(ContextHelper.java:23)
   at org.hibernate.search.query.FullTextQueryImpl.list(FullTextQueryImpl.java:228)
   at br.com.gtcon.jbancotalentos.jsf.managedbeans.admin.BuscaCurriculo.pesquisar(BuscaCurriculo.java:90)
   at br.com.gtcon.jbancotalentos.jsf.managedbeans.admin.BuscaCurriculo.buscar(BuscaCurriculo.java:112)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.apache.el.parser.AstValue.invoke(AstValue.java:172)
   at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
   at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
   at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:71)
   at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:95)
   at javax.faces.component.UICommand.broadcast(UICommand.java:384)
   at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:317)
   at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:292)
   at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:249)
   at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:462)
   at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
   at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:266)
   at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:132)
   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
   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:154)
   at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:260)
   at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:366)
   at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:493)
   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:233)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
   at java.lang.Thread.run(Unknown Source)


I´m using apache-tomcat 6.0.18, hibernate-distribution-3.3.1.GA, hibernate-annotations-3.4.0.GA and hibernate-search-3.0.1.GA
PS: sorry for my "bad" english

Thanks!


Last edited by finotti on Fri Jun 19, 2009 8:27 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Problems with Hibernate search + web project
PostPosted: Fri Jun 19, 2009 4:40 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Looks like a Session problem at the first glance. Are you sure you your Session object is not null. How do you use Hibernate within the webapp? Do you the Open Session in View pattern (https://www.hibernate.org/43.html)?

As a sidenode, I would not use a relative path in the index base. It is relative to the directory the JVM gets started in. In case you make some changes to the startup script Hibernate Search might not be able to find the indexes anymore. I also wouldn't place the indexes inside the exploded webapp. Instead I would use a dedicated index directory somewhere else on the file system.

--Hardy


Top
 Profile  
 
 Post subject: Re: Problems with Hibernate search + web project
PostPosted: Fri Jun 19, 2009 8:26 am 
Newbie

Joined: Thu Jun 18, 2009 9:39 am
Posts: 2
Hi Hardy.
The problem was solved. My session object was null.
Thanks for your reply.
[]'s


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.