-->
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.  [ 2 posts ] 
Author Message
 Post subject: Problem with configuring Hibernate Search Event listeners
PostPosted: Wed Jul 04, 2007 6:12 am 
Newbie

Joined: Wed Apr 11, 2007 8:48 am
Posts: 13
Hello

I am using EJB3 and JBoss 4.04 and Oracle 10. I have Hibernate EntityManager 3.2.0, Hibernate Annotations 3.2.0. Downloaded the latest version of Hibernate Search along with lucene-core-2.1.0 jar file.

In my program i have a simple entity bean Group and the following code in the SessionBean.

Code:
  public List searchByKeyword(String keyword) {
        BooleanQuery booleanQuery = new BooleanQuery();
        booleanQuery.add( new PrefixQuery( new Term( "name", keyword ) ), BooleanClause.Occur.SHOULD );
        org.hibernate.Query fullTextQuery = getFullTextSession().createFullTextQuery(booleanQuery, Group.class);
        List result = fullTextQuery.list();
        return result;
    }
   
    FullTextSession getFullTextSession() {
        org.jboss.ejb3.entity.HibernateSession hs = (HibernateSession)em;
        org.hibernate.Session session = hs.getHibernateSession();
        FullTextSession fullTextSession = Search.createFullTextSession(session);
        return fullTextSession;
    }


Here is the persistence.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
  <persistence-unit name="HibernateSearch-ejbPU" transaction-type="JTA">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <jta-data-source>java:/OracleDS</jta-data-source>
    <properties>
      <property name="hibernate.jdbc.batch_size" value="20"/>
      <property name="hibernate.search.default.directory_provider" value="org.hibernate.search.store.FSDirectoryProvider"/>
      <property name="hibernate.search.default.indexBase" value="/usr/lucene/indexes"/>
      <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect"/>
      <property name="hibernate.hbm2ddl.auto" value="update"/>
         </properties>
  </persistence-unit>
</persistence>


Whenever i call the method searchByKeyword from my client i get the following Exception at Client:
Code:
Caused by: org.hibernate.HibernateException: Hibernate Search Event listeners not configured, please check the reference documentation and the application's hibernate.cfg.xml
        at org.hibernate.search.util.ContextHelper.getSearchFactoryBySFI(ContextHelper.java:31)
        at org.hibernate.search.query.FullTextQueryImpl.list(FullTextQueryImpl.java:207)
        at sessions.GroupManagerBean.searchByKeyword(GroupManagerBean.java:126)
        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 org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
        at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
        at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
        at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:227)
        at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
        at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
        at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828)
        at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681)
        at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:358)
        at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:398)
        at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239)
        at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:190)
        at org.jboss.remoting.Client.invoke(Client.java:525)
        at org.jboss.remoting.Client.invoke(Client.java:488)
        at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:55)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:55)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:78)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:102)
        at $Proxy0.searchByKeyword(Unknown Source)
        at hibernatesearch.Main.main(Main.java:36)
Java Result: 1


Then i included the hibernate.cfg.xml file and gave its path in the persistence.xml. The hibernate.cfg.xml looked like this:
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
   <event type="pre-load">
      <listener class="org.hibernate.search.event.FullTextIndexEventListener"/>
   </event>
   <event type="post-load">
      <listener class="org.hibernate.search.event.FullTextIndexEventListener"/>
   </event>
   </session-factory>
</hibernate-configuration>


But still no luck. I am new with HibernateSearch. Maybe i am missing something. Please help.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 11, 2007 11:36 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Automatic event registration is available if you use Hibernate Annotations 3.3 and above.
Try and upgrade if you can.

If you cannot, then follow the instructions here to define the proper event listeners http://www.hibernate.org/hib_docs/search/reference/en/html_single/#search-configuration-event

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.