-->
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.  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Error: Hibernate Search Event listeners not configured
PostPosted: Tue Nov 13, 2007 5:10 pm 
Regular
Regular

Joined: Fri Oct 05, 2007 1:17 pm
Posts: 78
I am using Hibernate Annotiations, EntityManager, and JPA, and I have data in my database. When I attempt to manually index my database, I get the following:

Code:
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:32)
   at org.hibernate.search.util.ContextHelper.getSearchFactory(ContextHelper.java:18)
   at org.hibernate.search.impl.FullTextSessionImpl.getSearchFactoryImplementor(FullTextSessionImpl.java:160)
   at org.hibernate.search.impl.FullTextSessionImpl.index(FullTextSessionImpl.java:134)
   at org.hibernate.search.jpa.impl.FullTextEntityManagerImpl.index(FullTextEntityManagerImpl.java:65)
   at gov.nist.srm.persistence.util.test.SRMAdvancedSearchTest.generateIndexes(Unknown Source)
   at gov.nist.srm.persistence.util.test.SRMAdvancedSearchTest.testNameSearch(Unknown Source)
   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)
.
.
.
.



Here are my property settings in persistence.xml:

Code:
<persistence-unit name="srmPersistenceTest">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <properties>
         <property name="hibernate.show_sql" value="true" />
         <property name="hibernate.format_sql" value="true" />
         <property name="hibernate.archive.autodetection" value="class"/>
         <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect"/>
         <property name="hibernate.hbm2ddl.auto" value="update" />
         <property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver" />
         <property name="hibernate.connection.url" value="***"/>
         <property name="hibernate.connection.username" value="***" />
         <property name="hibernate.connection.password" value="***"/>
         <property name="hibernate.search.default.directory_provider" value="org.hibernate.search.store.FSDirectoryProvider"/>
         <property name="hibernate.search.default.indexBase" value="C:/search/indexes"/>
         <property name="hibernate.search.analyzer" value="org.apache.lucene.analysis.standard.StandardAnalyzer"/>
      </properties>
   </persistence-unit>


Here is the indexing code:

Code:
FullTextEntityManager fullTextEntityManager = Search.createFullTextEntityManager(em);
List items = em.createQuery("select item from ITEM as  item").getResultList();
     
      for (Object obj : items) {
         fullTextEntityManager.index(obj);
      }


I would appreciate any insight into what configuration setting I am missing here.

As a side note, and I know this is a JPA thing, but any insight as to how em.createQuery can return a collection of Items through generics would be appreciated as well.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 13, 2007 7:20 pm 
Newbie

Joined: Tue Aug 21, 2007 5:57 pm
Posts: 7
I think you need to set up org.hibernate.search.event.FullTextIndexEventListener's

See http://www.hibernate.org/hib_docs/searc ... le/#d0e874[code][/code]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 13, 2007 11:04 pm 
Regular
Regular

Joined: Fri Oct 05, 2007 1:17 pm
Posts: 78
Thanks. I saw that myself when I was doing my research, but I found this line:

"To enable Hibernate Search in Hibernate Core, add the FullTextIndexEventListener for the three Hibernate events that occur after changes are executed to the database. Once again, such a configuration is not useful with Hibernate Annotations or Hibernate EntityManager."

As I mentioned before, I am using JPA as an abstraction to Hibernate. I am not even sure how I would set those listeners in persistence.xml. But even still, I think the above means that that may not be the answer.

Of course, it is better than anything else I have come up with to this point!

Thanks again.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 14, 2007 6:08 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
It seems you are using a older version of Hibernate annotations.
You need version 3.3.x to have the transparent integration. I bet you're using 3.2.x

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 14, 2007 2:15 pm 
Regular
Regular

Joined: Fri Oct 05, 2007 1:17 pm
Posts: 78
Actually, because my project is using Seam, I am using all the Hibernate libraries, including Search, that come with Seam 2.0 GA. I took a look at hibernate-annotations.jar, and here is the manifest file:

Code:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.5
Created-By: 1.5.0_07-87 ("Apple Computer, Inc.")
Product: Hibernate Annotations
Version: 3.3.0.GA



Here is the manifest file from hibernate-commons-annotations.jar:

Code:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.5
Created-By: 1.5.0_07-87 ("Apple Computer, Inc.")
Product: Hibernate Commons Annotations
Version: 3.0.0.GA



Finally, here is the manifest file from hibernate-entitymanager.jar:

Code:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.5
Created-By: 1.5.0_07-87 ("Apple Computer, Inc.")
Product: Hibernate EntityManager
Version: 3.3.1.GA



Let me know if I can provide any more information.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 15, 2007 6:01 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Are you using Seam inside JBoss AS?
Which version?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 15, 2007 12:00 pm 
Regular
Regular

Joined: Fri Oct 05, 2007 1:17 pm
Posts: 78
No, all I am doing at the moment is running a TestNG test outside the container of my search class, which does things like use the Lucene query API to produce a query from user-provided values for an "advanced search" capability and generate results. (Sadly, I will be running on WL 9.2 and not JBoss, but that is just FYI and irrelevant to this discussion.)

The exception that I described is thrown in my test fixture setup method. Prior to the method call, DBUnit populates my database with known data. Then in my fixture setup method, I bootstrap an entity manager and do a "manual" index of the one table I will be searching on as shown in the code I provided in my initial message. It is just as I attempt to index the first item that I get that exception.

Please let me know what else I can provide. I am very excited about Hibernate Search, but this issue is really delaying my progress right now.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 16, 2007 5:18 pm 
Regular
Regular

Joined: Fri Oct 05, 2007 1:17 pm
Posts: 78
I have found when I run a SeamTest class in TestNG that it is easy to forget to supply something in your test fixture that would automatically be supplied by the container. The test fails as a result, and it is always really hard to determine why. Any insight you can provide as to something I may be missing in my persistence.xml would be helpful.

Incidentally, what are all the possible causes of the "Hibernate Search Event listeners not configured" error?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 17, 2007 3:31 pm 
Regular
Regular

Joined: Fri Oct 05, 2007 1:17 pm
Posts: 78
So I traced through the Hibernate Search source to see if I can figure anything out about this error. A couple of observations:

1) From the stack trace:

Code:
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:32)
   at org.hibernate.search.util.ContextHelper.getSearchFactory(ContextHelper.java:18)
   at org.hibernate.search.impl.FullTextSessionImpl.getSearchFactoryImplementor(FullTextSessionImpl.java:160)
   at org.hibernate.search.impl.FullTextSessionImpl.index(FullTextSessionImpl.java:134)
   at org.hibernate.search.jpa.impl.FullTextEntityManagerImpl.index(FullTextEntityManagerImpl.java:65)


The bottom line provided means I am certainly using Hibernate entity manager and JPA. And as it says in the documentation,

"Hibernate Search is enabled out of the box when using Hibernate Annotations or Hibernate EntityManager."

So this suggests I shouldn't need to do anything involving listeners if I am using either of those correctly.


2) Here is the Hibernate Search method in org.hibernate.search.util.ContextHelper that throws the exception:

Code:
public static SearchFactoryImplementor getSearchFactoryBySFI(SessionImplementor session) {
      PostInsertEventListener[] listeners = session.getListeners().getPostInsertEventListeners();
      FullTextIndexEventListener listener = null;
      //FIXME this sucks since we mandante the event listener use
      for ( PostInsertEventListener candidate : listeners ) {
         if ( candidate instanceof FullTextIndexEventListener ) {
            listener = (FullTextIndexEventListener) candidate;
            break;
         }
      }
      if ( listener == null ) throw new HibernateException(
            "Hibernate Search Event listeners not configured, please check the reference documentation and the " +
                  "application's hibernate.cfg.xml" );
      return listener.getSearchFactoryImplementor();
   }


The SessionImplementor object should have an array of PostInsertEventListeners, but the array is empty. I see how to provide such a thing in the documentation. However, that is supposed to be unnecessary with Hibernate EntityManager. Furthermore, I am unaware how to do the following in a JPA persistence.xml file:

Code:
<event type="post-insert"
            <listener class="org.hibernate.search.event.FullTextIndexEventListener"/>
</event>



Anyway, so I have done my homework, and it seems like either there is a bug in the code, or more likely I am missing a simple item in my persistence.xml, or even more likely I am failing to bootstrap something for TestNG in my SeamTest.

If Emmanuel or his team could speak to those possibilities, or if anyone has actually written a TestNG class to test their queries before deploying them, I would appreciate some insight.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 18, 2007 8:44 pm 
Regular
Regular

Joined: Fri Oct 05, 2007 1:17 pm
Posts: 78
Well, at the very least, I did figure out how to add listeners in persistence.xml--courtesy of the "dvdstore" sample in the Seam 2.0 GA distribution.

Here it is:

Code:
         <property name="hibernate.ejb.event.post-insert" value="org.hibernate.search.event.FullTextIndexEventListener"/>
         <property name="hibernate.ejb.event.post-update" value="org.hibernate.search.event.FullTextIndexEventListener"/>
         <property name="hibernate.ejb.event.post-delete" value="org.hibernate.search.event.FullTextIndexEventListener"/>         


Of course, the above is preceded by the following comment:

Code:
<!-- Not needed with HA 3.3 -->


As I mentioned in a previous message, I am indeed using HA 3.3. But you can't believe everything you read. Right, Matt Drudge?

At this point, my next steps are to make sure there isn't some sort of JAR file collision and to simply add these explicitly to my persistence.xml and see what happens.

Any insight or thoughts are encouraged.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 19, 2007 7:53 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
neilac333 wrote:
At this point, my next steps are to make sure there isn't some sort of JAR file collision and to simply add these explicitly to my persistence.xml and see what happens.


I am almost certain this is indeed some jar collision, you most likely have 2 Hibernate Annitations jars or 2 hibernate-entitymanger jars in your classpath (or one of the hibernate-all ish bundle).

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 19, 2007 2:02 pm 
Regular
Regular

Joined: Fri Oct 05, 2007 1:17 pm
Posts: 78
It turns out that we were both right. I had a stray hibernate-all.jar in my classpath, and clearly that was causing a bad collision. Once I removed it, the indexing process began nicely. I did find this:

Code:
org.hibernate.search.SearchException: Unable to guess FieldBridge for technicalCategory


But I cannot remember the last time I was so happy to see an exception!

I will study the documentation and start a new thread if I can't figure this one out on my own, but I appreciate the guidance on this listener issue.

Thank you, Emmanuel.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 10, 2008 6:21 am 
Newbie

Joined: Wed Sep 10, 2008 1:57 am
Posts: 2
Hmm ... I have the exact problem at the moment. I checked for JAR collision and I'm pretty sure everything's ok. I even deleted my project and recreate and carefully copy only required JARs. As for the JAR versions, I've just downloaded the latest Core, Annotations and Search so I guess it shouldn't be a problem. My xml configuration is exactly the same as the one posted in the first post.

I read from http://forum.hibernate.org/viewtopic.ph ... configured that 3 XML lines are not required. (I tested with and without anyway).

Below are my file versions, please let me know what I'm doing wrong.

hibernate-annotations-3.4.0.GA
hibernate-distribution-3.3.0.SP1
hibernate-search-3.0.1.GA

As for Lucene, I'm using the lucene-core-2.3.0.

Can someone enlighten me on what I did wrong? I've been searching and searching and I still haven't got my answer.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2008 6:29 am 
Newbie

Joined: Wed Sep 10, 2008 1:57 am
Posts: 2
Hmm .. The exception is gone after I changed the listeners configurations to

<listener type="post-insert" class="org.hibernate.search.event.FullTextIndexEventListener"/>
<listener type="post-update" class="org.hibernate.search.event.FullTextIndexEventListener"/>
<listener type="post-delete" class="org.hibernate.search.event.FullTextIndexEventListener"/>

No idea whether it really indexed though. Checked the index folder and there are some files there.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2008 7:31 am 
Beginner
Beginner

Joined: Thu Sep 11, 2008 5:33 am
Posts: 28
Hi,

even i have the same problem with my project.

what solution you have posted, i have tried that even but no success.

can you please explain your persistence.xml

your help would be appreciable :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 16 posts ]  Go to page 1, 2  Next

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.