I am upgrading to hibernate 6 with spring 5.
Following dependencies I have added:
implementation (group: ‘org.hibernate.search’, name: ‘hibernate-search-mapper-orm-jakarta’, version: ‘6.1.7.Final’){
exclude group: ‘org.hibernate.search’ , module: ‘hibernate-search-engine’
exclude group: ‘org.hibernate’, module: ‘hibernate-core-jakarta’
exclude group: ‘org.hibernate.common’, module: ‘hibernate-commons-annotations’
}
implementation (group: ‘org.hibernate.search’, name: ‘hibernate-search-backend-lucene’, version: ‘6.1.7.Final’){
exclude group: ‘org.hibernate.search’ , module: ‘hibernate-search-engine’
}
implementation group: ‘org.hibernate.orm’, name: ‘hibernate-core’, version: ‘6.1.4.Final’
implementation (group: ‘org.springframework.boot’, name: ‘spring-boot-starter-data-jpa’, version: ‘2.7.3’)
{
exclude group: ‘org.hibernate’, module: ‘hibernate-core’
exclude group: ‘jakarta.persistence’ , module: ‘jakarta.persistence-api’
exclude group: ‘org.springframework’, module: ‘spring-tx’
}
Now when I run the code it gives me the below-mentioned error:
Caused by: java.lang.NoClassDefFoundError: org/hibernate/MultiTenancyStrategy
at org.hibernate.search.mapper.orm.mapping.impl.HibernateOrmMappingInitiator.<init>(HibernateOrmMappingInitiator.java:93)
at org.hibernate.search.mapper.orm.mapping.impl.HibernateOrmMappingInitiator.create(HibernateOrmMappingInitiator.java:66)
at org.hibernate.search.mapper.orm.bootstrap.impl.HibernateSearchPreIntegrationService$NotBooted.doBootFirstPhase(HibernateSearchPreIntegrationService.java:242)
at org.hibernate.search.mapper.orm.bootstrap.impl.HibernateOrmIntegrationBooterImpl.bootNow(HibernateOrmIntegrationBooterImpl.java:173)
at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
at java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2147)
at org.hibernate.search.mapper.orm.bootstrap.impl.HibernateSearchSessionFactoryObserver.sessionFactoryCreated(HibernateSearchSessionFactoryObserver.java:41)
at org.hibernate.internal.SessionFactoryObserverChain.sessionFactoryCreated(SessionFactoryObserverChain.java:35)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:381)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:415)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:754)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:773)
at org.springframework.orm.hibernate5.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:616)
at org.springframework.orm.hibernate5.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:600)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800)
... 12 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.hibernate.MultiTenancyStrategy
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
... 29 common frames omitted
HibernateOrmMappingInitiator class is coming from hibernate-search-mapper-orm-jakarta-6.1.7.Final.jar. In this class, there is one import “org.hibernate.MultiTenancyStrategy” which is available in hibernate-core-5.6.12.Final.jar. But we have migrated to hibernate-core 6.1.4.Final. Also, the class for which I am getting error is available in hibernate-search-backend-lucene-6.1.7.Final.jar, having package name as “org.hibernate.search.backend.lucene.multitenancy.impl”.
Can anyone suggest why hibernate 6 jar is searching for an import that is available in hibernate 5, or why a wrong import is there in hibernate 6 jar.