Frage

I have been trying to integrate Spring with Hibernate Search but getting different exceptions with different versions. In my pom.xml I have following dependencies

<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-core</artifactId>
    <version>2.1.8.1</version>
</dependency>

<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-spring-plugin</artifactId>
    <version>2.1.8.1</version>
</dependency>
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.9</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring</artifactId>
    <version>2.5.6</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>2.5.6</version>
</dependency>
<dependency>
    <groupId>asm</groupId>
    <artifactId>asm-all</artifactId>
    <version>3.3</version>
</dependency>
<dependency>
    <groupId>asm</groupId>
    <artifactId>asm</artifactId>
    <version>3.3</version>
</dependency>
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>3.6.7.Final</version>
</dependency>

<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-convention-plugin</artifactId>
    <version>2.1.8.1</version>
</dependency>
<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-tiles-plugin</artifactId>
    <version>2.1.8.1</version>
    <scope>compile</scope>
</dependency>
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.0.1</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.15</version>
</dependency>
<dependency>
    <groupId>joda-time</groupId>
    <artifactId>joda-time</artifactId>
    <version>2.0</version>
</dependency>
<dependency>
    <groupId>commons-configuration</groupId>
    <artifactId>commons-configuration</artifactId>
    <version>1.6</version>
</dependency>

<dependency>
    <groupId>com.jgeppert.struts2.jquery</groupId>
    <artifactId>struts2-jquery-plugin</artifactId>
    <version>3.5.1</version>
</dependency>
<dependency>
    <groupId>com.jgeppert.struts2.jquery</groupId>
    <artifactId>struts2-jquery-grid-plugin</artifactId>
    <version>3.5.1</version>
</dependency>
<dependency>
    <groupId>com.jgeppert.struts2.jquery</groupId>
    <artifactId>struts2-jquery-richtext-plugin</artifactId>
    <version>3.5.1</version>
</dependency>
<dependency>
    <groupId>com.jgeppert.struts2.jquery</groupId>
    <artifactId>struts2-jquery-tree-plugin</artifactId>
    <version>3.5.1</version>
</dependency>
<dependency>
    <groupId>com.jgeppert.struts2.jquery</groupId>
    <artifactId>struts2-jquery-mobile-plugin</artifactId>
    <version>3.5.1</version>
</dependency>

I have also tried to get the actual version of hibernate (3.2.0 Final) from my tests so that I can easily compare the compatibility of hiberante search with my application's hiberante version.

String hibernateVersion = org.hibernate.annotations.common.Version.VERSION;
System.out.println("Hibernate Version: "+ hibernateVersion);

But whenever I just add these lines into my pom file

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-search</artifactId>
    <version>3.1.0.GA</version>
</dependency>

and try to deploy my application then it gives me an exception

ERROR org.springframework.web.context.ContextLoader.initWebApplicationContext:215 - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource ....
....
....
Caused by: java.lang.NoSuchMethodError: org.hibernate.util.SoftLimitMRUCache.<init>(I)V
War es hilfreich?

Lösung

Mandatory:

  • Change all Struts2 jars from 2.1.8.1 to 2.3.16
  • Change struts2-jquery-plugin from 3.5.1 to 3.7.0 (or it won't work with 2.3.16, only with lower versions)

Suggested:

  • Upgrade Hibernate to 4.x
  • Upgrade Spring to 3.x

If possible, use Hibernate as JPA2 implementation, instead of using it as raw Hibernate (old way). Then you will discover that Spring is no longer needed (for persistence at least), especially if you are using JAVA EE 6.

P.S: you will need to upgrade also Apache Commons and other shared libraries according to the latest version, just use Maven Repository to get the proper version numbers.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top