Spring + Hibernate Search 3.1.0 = ArrayStoreException
I'm using Spring Framework version 3.0.0 (although, I'll bet the same problem would happen with 2.x). I'm using Hibernate Search 3.1.0 (That's what's in Maven. I wonder why there's no 3.1.1).
Trying to use the configuration as follows inside of a Spring configuration document.
<property name="eventListeners">
<map>
<entry key="post-update" value-ref="fullTextEventListener" />
<entry key="post-delete" value-ref="fullTextEventListener" />
<entry key="post-insert" value-ref="fullTextEventListener" />
<entry key="flush">
<list>
<bean class="org.hibernate.event.def.DefaultFlushEventListener" />
<ref local="fullTextEventListener" />
</list>
</entry>
</map>
</property>
<map>
<entry key="post-update" value-ref="fullTextEventListener" />
<entry key="post-delete" value-ref="fullTextEventListener" />
<entry key="post-insert" value-ref="fullTextEventListener" />
<entry key="flush">
<list>
<bean class="org.hibernate.event.def.DefaultFlushEventListener" />
<ref local="fullTextEventListener" />
</list>
</entry>
</map>
</property>
Upon running some unit tests, I get a nasty Exception stack, with the following at the root.
Caused by: java.lang.ArrayStoreException at java.lang.System.arraycopy(Native Method) at java.util.ArrayList.toArray(ArrayList.java:306) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:759) at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1460) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1398) ... 57 more
The root cause of the problem (and I needed to debug the Spring/Hibernate internals to figure this out) is that FullTextIndexEventListener does not implement the FlushEventListener interface in version 3.1.0, but it does in 3.1.1.
Solution: upgrade (if you're using Maven, try the JBoss repository which has the latest stuff) or omit the "flush" event from the configuration.

