Tuesday, January 24, 2017

Hibernate ORM and Hibernate Search version compatibility issues.

We are migrating a complex e-commerce application, which has apache lucene indexing implemented for key entities, and while migrating to latest technology libraries of hibernate and hibernate search, we have faced some version incompatibility issues.

Initially, we tried to migrate from hibernate 4.4.4 Final to hibernate 5.2.6 and hibernate-search from 4.1.1 to hibernate-search-orm 5.5.6 (which is the current stable version) with lucene-queryparser 5.3.2(This needs to be explicitly added as dependency for this version of hibernate-search).

With the above combinations, application complies, container starts fine without any warnings.

But, the application failed while indexing an entity with the below error.

java.lang.NoSuchMethodError: org.hibernate.event.spi.EventSource.getTransactionCoordinator

The reason for the above errors seems that the current stable release of hibernate-search-orm is not buuilt on hibernate 5.2.x version of hibernate. Then we changed the hibernate-search-orm to its beta version 5.7.0.Beta2 which is the latest as on writing this. This change has resolved the above error. But, this change has caused another error while booting the application, this time with the lucene-queryparser.

java.lang.ClassNotFoundException: org.apache.lucene.search.similarities.ClassicSimilarity

To resolve this we got to migrate to lucene-queryparser 5.4.1, which is the next minimum compatible version with hibernte-search-orm, though the highest available version of lucene-queryparser is 6.4.1 at this time.

So, the following are the compatible versions that worked for us as on writing this.

hibernate-core and hibernate-entitymanaager - 5.2.6.Final
hibernate-search-orm - 5.7.0.Beta2
lucene-queryparser - 5.4.1

We find this is a real difficulty for people who try to migrate without closely following the community. Hibernate community should create compatible builds for each sub project and make them available to allow teams to migrate easily.