title: spring testing: Another CacheManager with same name 'myCacheManager' already exists in the same VM
body: <p>Before you mark this as duplicate please read the question first. I've read all the stuff about this exception however it does not solve the issue for me. And I do get a slightly different exception eg <code>Another CacheManager with same name 'myCacheManager' already exists</code> instead of <code>Another unnamed CacheManager already exists</code>.</p>
  
  <p>Spring config:</p>
  
  <pre><code>&lt;cache:annotation-driven cache-manager="cacheManager"/&gt;
  
  &lt;bean id="cacheManager"
        class="org.springframework.cache.ehcache.EhCacheCacheManager"
        p:cacheManager-ref="ehcache"/&gt;
  &lt;bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
        p:configLocation="ehcache.xml"
        p:cacheManagerName="myCacheManager"
        p:shared="true"/&gt;
  </code></pre>
  
  <p>ehcache</p>
  
  <pre><code>&lt;ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
          updateCheck="false" name="myCacheManager"&gt;
  
  &lt;/ehcache&gt;
  </code></pre>
  
  <p>The Problem is that I have 1 (in the future more) test classes that test security. these classes also load a SecurityContext.xml</p>
  
  <p>So most test classes have this annotations:</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration("classpath:ApplicationContext.xml")
  </code></pre>
  
  <p>However the class causing the issue:</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration(locations = {
      "classpath:ApplicationContext.xml",
      "classpath:SecurityContext.xml"
  })
  </code></pre>
  
  <p>It seems since locations are different the context is loaded again but ehcacheManager is still active from previous test.</p>
  
  <p>Note: this happens only when running multiple tests (eg. like clean + build). Running this test class separately works perfectly fine.</p>
  
  <p>Whats the issue? How can I solve it?</p>