Announcement Announcement Module
Collapse
No announcement yet.
Basic Spring 3.1 + Ehcache config problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Basic Spring 3.1 + Ehcache config problem

    Hi,

    I've been trying to configure Spring 3.1 to use Ehcache, but keep running into this exception:

    <failed to load application context, blah blah>

    Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.springframework.cache.config.internalCacheAsp ect': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: net/sf/ehcache/CacheManager
    [testng]


    Here are my changes to spring-context.xml:

    ...
    xmlns:cache="http://www.springframework.org/schema/cache"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    ...
    http://www.springframework.org/schema/cache
    http://www.springframework.org/schema/cache/spring-cache-3.1.xsd">



    <!-- The EhCache cache manager -->
    <cache:annotation-driven cache-manager="cacheManager"/>

    <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCa cheManager">
    <property name="cacheManager" ref="ehcache" />
    </bean>
    <!-- Ehcache library setup -->
    <bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheMa nagerFactoryBean" >
    <property name="configLocation" value="classpath:ehcache.xml" />
    </bean>


    And here is my ehcache.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <ehcache>
    <diskStore path="java.io.tmpdir"/>
    <cache name="mycache"
    maxElementsInMemory="100"
    eternal="false"
    timeToIdleSeconds="120"
    timeToLiveSeconds="120"
    overflowToDisk="true"
    maxElementsOnDisk="10000000"
    diskPersistent="false"
    diskExpiryThreadIntervalSeconds="120"
    memoryStoreEvictionPolicy="LRU"/>

    </ehcache>

    My classpath contains all of these:


    org.springframework.aop-3.1.0.M2.jar
    org.springframework.asm-3.1.0.M2.jar
    org.springframework.aspects-3.1.0.M2.jar
    org.springframework.jdbc-3.1.0.M2.jar
    org.springframework.core-3.1.0.M2.jar
    org.springframework.beans-3.1.0.M2.jar
    org.springframework.context-3.1.0.M2.jar
    org.springframework.context.support-3.1.0.M2.jar
    org.springframework.transaction-3.1.0.M2.jar
    org.springframework.web-3.1.0.M2.jar
    org.springframework.test-3.1.0.M2.jar

    And furthermore I have a DAOImpl class with a method that has @Cacheable("mycache").

    I'm sure the problem is obvious, but I don't understand why Spring is looking for net.sf.ehcache.CacheManager instead of using the ehcache that is now built in. I don't have any of the standalone ehcache jars in the classpath.

    Thanks in advance for any help!

  • #2
    Please use [ code][/code ] tags when posting code that way it remains readable..

    I'm sure the problem is obvious, but I don't understand why Spring is looking for net.sf.ehcache.CacheManager instead of using the ehcache that is now built in. I don't have any of the standalone ehcache jars in the classpath.
    There is nothing of ehcache build in only an abstraction layer, you will still need EhCache as a cache implementation! Just like as with JPA or whatever other abstraction spring has/utilizes. It only makes it easier to work with the framework.

    Comment


    • #3
      Hi Marten,

      Noted about the [code] tags.

      Thanks! Wow, that would explain a lot.

      I'm a newbie to Spring if that wasn't obvious. Appreciate the help.

      Comment

      Working...
      X