0

I keep getting this error while setting up ehcache in Spring MVC.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.googlecode.ehcache.annotations.config.internalEhCacheEvictionTask': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: net.sf.ehcache.CacheManager.getName()Ljava/lang/String;

Below is my setup, and I am using hibernate 3.2.7.GA

<ehcache:config cache-manager="ehCacheManager">
    <ehcache:evict-expired-elements interval="60" />
</ehcache:config>

<beans:bean id="ehCacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
    <beans:property name="configLocation"  value="/WEB-INF/spring/ehcache.xml"/>
</beans:bean>

Pom.xml

<dependency>
          <groupId>com.googlecode.ehcache-spring-annotations</groupId>
          <artifactId>ehcache-spring-annotations</artifactId>
          <version>1.1.3</version>
        </dependency>
        <dependency>
            <groupId>net.sf.ehcache</groupId>
            <artifactId>ehcache-core</artifactId>
            <version>2.3.2</version>
        </dependency>
        <dependency>
           <groupId>net.sf.ehcache</groupId>
           <artifactId>ehcache</artifactId>
           <version>2.3.2</version>
           <type>pom</type>
       </dependency>
    </dependencies>
    <repositories>
          <repository>
            <id>terracotta-releases</id>
            <url>http://www.terracotta.org/download/reflector/releases</url>
            <releases><enabled>true</enabled></releases>
            <snapshots><enabled>false</enabled></snapshots>
        </repository>

2 Answers 2

2

The zip file of ehcache-spring-annotations containing the dependencies, downloaded on the project web site, contains ehcache-core version 2.2.0. You're using 2.3.2. There might be an incompatibility between those versions.

Sign up to request clarification or add additional context in comments.

Comments

1

Got it working by using an exclude, so yes there was a clash issue.

   <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-commons-annotations</artifactId>
                <version>${org.hibernate.commons.annotations-version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>net.sf.ehcache</groupId>
                        <artifactId>ehcache</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.