Hibernate Search upgrade from 7.2.4 to 8.0.0

Hi!

When I try to upgrade Hibernate Search from 7.2.4 to 8.0.0 there is an error preventing application start:

***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
    org.hibernate.search.mapper.orm.bootstrap.impl.HibernateOrmIntegrationBooterImpl.<init>(HibernateOrmIntegrationBooterImpl.java:75)
The following method did not exist:
    'org.hibernate.models.spi.ModelsContext org.hibernate.boot.spi.BootstrapContext.getModelsContext()'
The calling method's class, org.hibernate.search.mapper.orm.bootstrap.impl.HibernateOrmIntegrationBooterImpl, was loaded from the following location:
    jar:file:/C:/Users/Hrvoje/.m2/repository/org/hibernate/search/hibernate-search-mapper-orm/8.0.0.Final/hibernate-search-mapper-orm-8.0.0.Final.jar!/org/hibernate/search/mapper/orm/bootstrap/impl/HibernateOrmIntegrationBooterImpl.class
The called method's class, org.hibernate.boot.spi.BootstrapContext, is available from the following locations:
    jar:file:/C:/Users/Hrvoje/.m2/repository/org/hibernate/orm/hibernate-core/6.6.15.Final/hibernate-core-6.6.15.Final.jar!/org/hibernate/boot/spi/BootstrapContext.class
The called method's class hierarchy was loaded from the following locations:
    org.hibernate.boot.spi.BootstrapContext: file:/C:/Users/Hrvoje/.m2/repository/org/hibernate/orm/hibernate-core/6.6.15.Final/hibernate-core-6.6.15.Final.jar
Action:
Correct the classpath of your application so that it contains compatible versions of the classes org.hibernate.search.mapper.orm.bootstrap.impl.HibernateOrmIntegrationBooterImpl and org.hibernate.boot.spi.BootstrapContext

The only difference was:

BooleanPredicateClausesStep<?> 

which I had to change to:

BooleanPredicateClausesStep<?,?> 

Other versions are:
Java: 21
Spring Boot: 3.5.0
Hibernate 7.0.2.Final

<properties>
	<!-- <hibernate-search-mapper-orm.version>7.2.4.Final</hibernate-search-mapper-orm.version> -->
	<hibernate-search-mapper-orm.version>8.0.0.Final</hibernate-search-mapper-orm.version>
</properties>

<dependencies>

	<dependency>
		<groupId>org.hibernate.search</groupId>
		<artifactId>hibernate-search-mapper-orm</artifactId>
		<version>${hibernate-search-mapper-orm.version}</version>
		<exclusions>
			<exclusion>
				<groupId>org.hibernate.orm</groupId>
				<artifactId>hibernate-core</artifactId>
			</exclusion>
			<exclusion>
				<groupId>org.jboss.logging</groupId>
				<artifactId>jboss-logging</artifactId>
			</exclusion>
		</exclusions>
	</dependency>

	<dependency>
		<groupId>org.hibernate.search</groupId>
		<artifactId>hibernate-search-backend-lucene</artifactId>
		<version>${hibernate-search-mapper-orm.version}</version>
		<exclusions>
			<exclusion>
				<groupId>org.jboss.logging</groupId>
				<artifactId>jboss-logging</artifactId>
			</exclusion>
		</exclusions>
	</dependency>

</dependencies>

When I exclude old Hibernate Core (6.*) and manually add new Hibernate Core (7.0.2), then I get:

Caused by: java.lang.ClassNotFoundException: jakarta.persistence.PersistenceUnitTransactionType

which reminds me of the way I don’t want to go before asking.

Hey hey :waving_hand:

hmm yeah … this looks like a problem with dependencies :confused:
You’d want

  • Hibernate ORM 7.0
  • Hibernate Search 8.0
  • Hibernate Models 1.0 (above two should take care of that, but versions in ORM 7.0.0 and Search 8.0.0 are different and things won’t work nicely if you don’t force the version Search expects) but since you are already at 8.0.0 and 7.0.2 this shouldn’t be a problem
  • Jakarta Persistence 3.2.0

I suspect that Spring brings its own versions of some of the above and it is causing the issues … try running mvn dependency:tree to see what ends up in your dependencies and from where it comes from..

see the missing jakarta.persistence.PersistenceUnitTransactionType tells that it’s there since 3.2: PersistenceUnitTransactionType (Jakarta Persistence API documentation) :confused:

1 Like

One other hing I just though I’d mention to you, you know there’s the Hibernate Search BOM and Hibernate ORM platform files, right?

so if you do something like this:

where you import the ORM platform + Search BOM before any Spring dependencies it may save you some troubles…

Thank you very much!
Now it’s working!
I had to add Jakarta Persistence 3.2 on top of all.

	<properties>

		         <hibernate-core.v>7.0.2.Final</hibernate-core.v>
		<jakarta.persistence-api.v>3.2.0</jakarta.persistence-api.v>
		       <hibernate-search.v>8.0.0.Final</hibernate-search.v>

	</properties>

	<dependencies>

			<dependency>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-starter-data-jpa</artifactId>
				<exclusions>
					<exclusion>
						<groupId>org.hibernate.orm</groupId>
						<artifactId>hibernate-core</artifactId>
					</exclusion>
				</exclusions>
			</dependency>

			<dependency>
			    <groupId>org.hibernate.orm</groupId>
			    <artifactId>hibernate-core</artifactId>
			    <version>${hibernate-core.v}</version><!--$NO-MVN-MAN-VER$-->
			</dependency>

			<dependency>
				<groupId>jakarta.persistence</groupId>
				<artifactId>jakarta.persistence-api</artifactId>
				<version>${jakarta.persistence-api.v}</version><!--$NO-MVN-MAN-VER$-->
			</dependency>

			<dependency>
				<groupId>org.hibernate.search</groupId>
				<artifactId>hibernate-search-mapper-orm</artifactId>
				<version>${hibernate-search.v}</version>
				<exclusions>
					<exclusion>
						<groupId>org.hibernate.orm</groupId>
						<artifactId>hibernate-core</artifactId>
					</exclusion>
					<exclusion>
						<groupId>org.jboss.logging</groupId>
						<artifactId>jboss-logging</artifactId>
					</exclusion>
				</exclusions>
			</dependency>

			<dependency>
				<groupId>org.hibernate.search</groupId>
				<artifactId>hibernate-search-backend-lucene</artifactId>
				<version>${hibernate-search.v}</version>
				<exclusions>
					<exclusion>
						<groupId>org.jboss.logging</groupId>
						<artifactId>jboss-logging</artifactId>
					</exclusion>
				</exclusions>
			</dependency>

			<dependency>
				<groupId>org.jboss.logging</groupId>
				<artifactId>jboss-logging</artifactId><!--$NO-MVN-MAN-VER$-->
			</dependency>

	</dependencies>
1 Like