Jay2008 (8) [Avatar] Offline
When i place the @Index annotation on my entity i get the following exception from Spring:

Caused by: org.hibernate.AssertionFailure: could not init listeners
at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:199)
at org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:1315)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1304)

I am assuming these are the listeners that update the Lucene Index when deleting, updating, adding an indexable entity? I have searched the and found the example:

<bean id="sessionFactory" >
<property name="dataSource" ref="myDataSource"/>
<property name="annotatedClasses">
<property name="hibernateProperties">
<prop key="hibernate.search.default.indexBase">/home/iuliana/lucene/index</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
<prop key="hibernate.search.default.directory_provider">org.hibernate.search.store.FSDirectoryProvider</prop>
<property name="eventListeners">
<entry key="post-update">
<bean class="org.hibernate.search.event.FullTextIndexEventListener"/>
<entry key="post-insert">
<bean class="org.hibernate.search.event.FullTextIndexEventListener"/>
<entry key="post-delete">
<bean class="org.hibernate.search.event.FullTextIndexEventListener"/>


But the exception is still being thrown. What is the correct way to register the relevant hibernate event listeners with spring?

Many thanks
emmanuel.bernard (101) [Avatar] Offline
Re: how to integrate spring 2.5.5 with hibernate search
which version of hibernate core, and search are you using?
Jay2008 (8) [Avatar] Offline
Re: how to integrate spring 2.5.5 with hibernate search
I'm using Hibernate Search 3.0.1, Hibernate Core 3.3.0.

I figured out through testing that the @Index is ok. The problem is with the @Analyzer annotaton:

@Analyzer(impl = SnowballAnalyzer.class)
public class ZProduct implements java.io.Serializable {

If i set this to: @Analyzer(impl = StandardAnalyzer.class) then it's ok and no errors occur. So how do i configure the use of the SnowballAnalyzer?

I am using lucene-snowball-2.3.0.jar for this analyzer.

Many thanks for your time
john.griffin (36) [Avatar] Offline
Re: how to integrate spring 2.5.5 with hibernate search

This looks like a Jira issue to me. What do you think Emmanuel?

Would you open an issue at http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH, please.


John G.
emmanuel.bernard (101) [Avatar] Offline
Re: how to integrate spring 2.5.5 with hibernate search
You have hit

which hide the underlying exception. Both are fixed in the new Hibernate Core 3.3.0.CR2 version. Give it a try.

for you actual problem, I think you use the vanilla SnowballAnalyzer (provided by Lucene). It does not have an no-arg constructor and hence the exceptions.
Two solutions:
- write a special SnowballAnalyzer with a no arg constructor delegating to the real one
- use Hibernate Search 3.1 (Beta1 at the moment)

Hibernate Search 3.1 (which has been designed to work with Hibernate Core 3.3) does support a neat notion

tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class ),
filters = { @TokenFilterDef(factory = StandardFilterFactory.class),
@TokenFilterDef(factory = LowerCaseFilterFactory.class),
@TokenFilterDef(factory = StopFilterFactory.class),
@TokenFilterDef(factory = SnowballPorterFilterFactory.class,
params = @Parameter(name="language",
value="English" ) ) }


@Field( index = Index.TOKENIZED, store = Store.YES )
private String text;

If you can jump onto the 3.1 wagon.

PS: be careful about this bug http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-232
We are working with the Solr team to get that sorted out. In the mean time you need to full Solr JAR.
emmanuel.bernard (101) [Avatar] Offline
Re: how to integrate spring 2.5.5 with hibernate search
Forgot to say the analyzer def feature and analyzers are descriped in section 5.3 of Hibernate Search in Action
bpmm (34) [Avatar] Offline
I am working on the indexations fields and I have a problem which to capture event listeners during run my application, although the configuration has been done with this file applicationContext-dev.xml.
bpmm (34) [Avatar] Offline
hibernate search
I am looking solutions on querying and exactlly to know hibernate search used his technic to process a query. Example, I want to search on database two names such as TOM and JOHN, what's the operators used either OR, either AND or parenthesis to select words or sentences...?
I hope to solve this situation and obtain help.