title: problem creating an EhCache Cache from spring
body: <p>Reading the javadoc for <a href="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/cache/ehcache/EhCacheManagerFactoryBean.html" rel="nofollow noreferrer">EhCacheManagerFactoryBean</a> and <a href="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/cache/ehcache/EhCacheFactoryBean.html" rel="nofollow noreferrer">EhCacheFactoryBean</a> I figured that: </p>
  
  <pre><code>&lt;bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" p:configLocation="classpath:ehcache.xml"/&gt;
  
  &lt;bean id="locationCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean"
        p:cacheManager-ref="cacheManager"
        p:cacheName="locationCache"/&gt;
  </code></pre>
  
  <p>would create a cache that I then can @Autowired in. But I must be missing something because this is what I get:</p>
  
  <blockquote>
    <p>Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'locationCache' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: net.sf.ehcache.Cache.(Ljava/lang/String;ILnet/sf/ehcache/store/MemoryStoreEvictionPolicy;  ZLjava/lang/String;ZJJZJLnet/sf/ehcache/event/RegisteredEventListeners;  Lnet/sf/ehcache/bootstrap/BootstrapCacheLoader;II)V</p>
  </blockquote>
  
  <p>I've tried ehcache 1.7.2, 1.6.2 and 1.5.0.</p>
  
  <p>It works if I specify <code>&lt;cache name="locationCache" /&gt;</code> in ehcache.xml but I prefer to have my configuration done in applicationsContext.xml</p>
  
  <pre><code>&lt;cache name="locationCache" /&gt; 
  </code></pre>