[jboss-user] Hibernate-search problems in JBoss

Richard Boehme rboehme at gmail.com
Thu Sep 20 15:06:17 EDT 2007


I'm not sure if here or the Hibernate mailing list was the correct
place to post this, so I'm reposting this here in case anyone here has
ideas on this.

Hi there. I'm having problems using hibernate-search. I'm running on
Hibernate 3.2.4, hibernate-annotations-3.3.0.GA, and
hibernate-search-3.0.0.CR1. I'm also using Spring 2.0.6 and JBoss
4.2.1.GA. Now that I've got the version details out of the way, on to
the problem:

When I try to index a class that should be indexable, Hibernate dups a
stack trace starting with:

Hibernate Search Event listeners not configured, please check the
reference documentation and the application's hibernate.cfg.xml


I have followed the directions in the Hibernate search documentation
on creating a hibernate index; I've annotated the class that I want to
search and configured my sessionFactory's HibernateProperties to add
the directory_provider and indexBase in my
applicationContext-hibernate.xml.

@Entity
@Indexed
public class ZZZ extends YYY
{

  @DocumentId
  private Long id;

  @Field(index=Index.TOKENIZED, store=Store.NO)
  private String zzzId;


.
.
.


<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
       <property name="dataSource"><ref bean="dataSource"/></property>
       <property name="mappingResources">
           <list>
               <value>com/adaptiverfid/model/ZZZ.hbm.xml</value>
               <!-- snip more details -->
           </list>
       </property>

       <property name="hibernateProperties">
       <props>
           <!-- snip working database details -->
           <prop
key="hibernate.search.default.directory_provider">org.hibernate.search.store.FSDirectoryProvider</prop>
           <prop
key="hibernate.search.default.indexBase">/path/to/already/created/dir</prop>
       </props>
       </property>
   </bean>


I also have the hibernate-search, hibernate-annotations,
hibernate-commons-annotations, and lucene jars in my classpath. I have
tried adding post-commit-update, post-commit-delete- and
post-commit-update eventListeners to the sessionFactory bean, but that
doesn't help.

Googling gives me a version control entry that indicates that message
had been changed to be clearer than the one that said that the Lucene
event listeners need to be configured.

My indexing function is per the documentation's example; I simply pass
my list of objects to index in and it indexes them (I've also tried
commenting out the transaction, with the same results).

public void reindexForSearch(List list)
   {
     Session session =
SessionFactoryUtils.getSession(this.getSessionFactory(), true);
     FullTextSession fullTextSession = Search.createFullTextSession(session);
     Transaction tx = fullTextSession.beginTransaction();
     for(Object obj : list)
     {
       fullTextSession.index(obj);
     }
     tx.commit();
     SessionFactoryUtils.releaseSession(session, this.getSessionFactory());
   }


My question: what is causing this error? The only configuration
document that gives me much information is the Hibernate search
documentation, which doesn't provide many more details relating to
getting this most basic scenario to work other than 'this is the
simple example, and the first step'. I'm also unclear on if I need to
put the post-commit event listeners in my
applicationContext-hibernate.xml file, and if I do what the right way
to do it is.

Thank you for the help.

Richard



More information about the jboss-user mailing list