2

I am trying to integrate Hibernate Search with existing Spring MVC application where I have used hibernate ORM to communicate with Database.

When I add Hibernate Search dependencies in the pom.xml, it is throwing below error.

    [com/poc/configuration/HibernateConfiguration.class]: 
    Invocation of init method failed; nested exception is      
    java.lang.NoClassDefFoundError: org/hibernate/service/spi/BasicServiceInitiator.

Here is my pom.xml file.

    <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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.wex.poc</groupId>
<artifactId>spring-security</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>spring-security Maven Webapp</name>
<url>http://maven.apache.org</url>

<properties>
    <springframework.version>4.2.4.RELEASE</springframework.version>
    <springsecurity.version>4.0.3.RELEASE</springsecurity.version>
    <hibernate.version>4.3.11.Final</hibernate.version>
    <hibernate.search.version>4.4.0.Final</hibernate.search.version>
    <jstl.version>1.2</jstl.version>
</properties>
<dependencies>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-search-engine</artifactId>
        <version>${hibernate.search.version}</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-search-orm</artifactId>
        <version>{hibernate.search.version}</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.5.0</version>
    </dependency>
    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.3-1100-jdbc41</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
        <scope>provided</scope>
    </dependency>
    <!-- Spring -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${springframework.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${springframework.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${springframework.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>${springframework.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>${springframework.version}</version>
    </dependency>


    <!-- Spring Security -->
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>${springsecurity.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
        <version>${springsecurity.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-taglibs</artifactId>
        <version>${springsecurity.version}</version>
    </dependency>


    <!-- Hibernate -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>${hibernate.version}</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>${jstl.version}</version>
    </dependency>

</dependencies>
<build>
    <finalName>spring-security</finalName>
</build>

I know that it is because of the version conflicts between hibernate and hibernate search.

But I am unable to figure out the correct combination.

Please let me know if anyone has idea about this.

Raghavendra
  • 3,876
  • 4
  • 22
  • 41

3 Answers3

1

If you want to use Hibernate ORM version 4.3.x, the last stable release of Hibernate Search supporting it is Hibernate Search version 5.3.0.Final

You can not freely mix any combination of dependencies: we document the compatible ranges in the README, on the downloads pages, on the Migration Guides and of course in the reference documentation.

If in doubt, please check the pom.xml files of the sources on GitHub.

Sanne
  • 6,027
  • 19
  • 34
0

It's existing Hibernate Search issue. Posible solutions you can find in comments.

svichkar
  • 1,806
  • 1
  • 17
  • 23
  • No it's not. We never intended this much older Hibernate Search version to be compatible with the never Hibernate ORM: we clearly document which versions are compatible. Please see my answer. – Sanne Mar 22 '16 at 12:45
0

Hibernate Search is causing this issue with Hibernate Core 4.3.0. Hibernate resolved most of the compatibility issues, you can check in more detail at GIT Hub project.

Sai prateek
  • 11,842
  • 9
  • 51
  • 66
  • Hibernate Search is not causing any issue. People need to use the right versions. +1 to always check the github project! – Sanne Mar 22 '16 at 12:53