3

I'm trying to setup Spring Boot 3.0.1 project from scratch using latest versions. So far I managed to get working mvc and repositories, but while adding Hibernate Search, things won't work anymore.

Below you can see my pom.xml file.

When I go to "Dependency Hierarchy" (Eclipse STS), I can find hibernate-core 5.6.11.Final embedded with hibernate-search-mapper-pojo-base 6.1.7.Final which is embedded into hibernate-search-mapper-orm 6.1.7.Final. Does it mean I have to manually exclude this one and include higher version? Also hibernate-core 5.6.11.Final has hibernate-commons-annotations 5.1.2.Final embedded. Why is it so complicated? Is there something I'm missing?

In the console log I get this:

***************************
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.cfg.annotations.BasicValueBinder.resolveJavaType(BasicValueBinder.java:1002)

The following method did not exist:

    'java.lang.reflect.Type org.hibernate.annotations.common.reflection.ReflectionManager.toType(org.hibernate.annotations.common.reflection.XClass)'

The calling method's class, org.hibernate.cfg.annotations.BasicValueBinder, was loaded from the following location:

    jar:file:/C:/Users/Hrvoje/.m2/repository/org/hibernate/orm/hibernate-core/6.1.6.Final/hibernate-core-6.1.6.Final.jar!/org/hibernate/cfg/annotations/BasicValueBinder.class

The called method's class, org.hibernate.annotations.common.reflection.ReflectionManager, is available from the following locations:

    jar:file:/C:/Users/Hrvoje/.m2/repository/org/hibernate/common/hibernate-commons-annotations/5.1.2.Final/hibernate-commons-annotations-5.1.2.Final.jar!/org/hibernate/annotations/common/reflection/ReflectionManager.class

The called method's class hierarchy was loaded from the following locations:

    org.hibernate.annotations.common.reflection.ReflectionManager: file:/C:/Users/Hrvoje/.m2/repository/org/hibernate/common/hibernate-commons-annotations/5.1.2.Final/hibernate-commons-annotations-5.1.2.Final.jar


Action:

Correct the classpath of your application so that it contains compatible versions of the classes org.hibernate.cfg.annotations.BasicValueBinder and org.hibernate.annotations.common.reflection.ReflectionManager
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.0.1</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>net.horvoje</groupId>
    <artifactId>TheVegCat2</artifactId>
    <version>1.0</version>
    <packaging>war</packaging>
    <name>TheVegCat2</name>
    <description>The Vegan Catalog II</description>
    <properties>
        <java.version>17</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-cache</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thymeleaf.extras</groupId>
            <artifactId>thymeleaf-extras-springsecurity6</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>

<!-- Hibernate Search begin -->

        <dependency>
            <groupId>org.hibernate.search</groupId>
            <artifactId>hibernate-search-mapper-orm</artifactId>
            <version>6.1.7.Final</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate.search</groupId>
            <artifactId>hibernate-search-backend-lucene</artifactId>
            <version>6.1.7.Final</version>
        </dependency>

<!-- Hibernate Search end -->

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

horvoje
  • 643
  • 6
  • 21

1 Answers1

5

Well, looks like the Internet is not ready for new versions of Hibernate 6 and Hibernate Search 6. To avoid this error, I had to remove dependency hibernate-search-mapper-orm and add this one: hibernate-search-mapper-orm-orm6.

When you search maven repository and enter "hibernate search orm", this one comes up as a 10th result which I didn't see because 2nd place already did not have search terms I wrote.

Looks like this one is to be used with Hibernate 6 and - at least for me - it was hard to find.

<dependency>
    <groupId>org.hibernate.search</groupId>
    <artifactId>hibernate-search-mapper-orm-orm6</artifactId>
    <version>6.1.7.Final</version>
</dependency>
horvoje
  • 643
  • 6
  • 21
  • 1
    See also https://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#other-integrations-orm6 and https://hibernate.org/search/releases/#compatibility-matrix – yrodiere Jan 09 '23 at 14:32
  • 1
    @horvoje you're a God send buddy. I spent 2 days (and God knows how much longer) trying to figure this out. Like you I faced a criss-cross between Hibernate 5 and 6 libs. I also tried to exclude stuff. The documentation on the Hibernate Search site sucks. It doesn't have a section for Spring Boot 3. I also never saw: hibernate-search-mapper-orm-orm6 mentioned anywhere. At least my project is compiling now. Hopefully it will search too! If you have a github example of Hibernate Search you can share, that would be super helpful. Thank you. – logixplayer Jan 27 '23 at 03:38