2016-09-19 2 views
1

ehcacheとSpringでtomcatを開始するときにこのエラーが発生します。同じ名前の別のCacheManager 'cacheManager'がすでに同じVMに存在しています

Another CacheManager with same name 'cacheManager' already exists in the same VM. Please 
provide unique names for each CacheManager in the config or do one of following: 
1. Use one of the CacheManager.create() static factory methods to reuse same 
    CacheManager with same name or create one if necessary 
2. Shutdown the earlier cacheManager before creating new one with same name. 
  • スプリング3.1
  • ehcacheを2.9.0
  • これを用いた無テスト・コンテキスト。
  • これはWeb JSFアプリケーションです。

ehcache.xml

  <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:noNamespaceSchemaLocation="ehcache.xsd" 
      updateCheck="true" 
      monitoring="autodetect" 
      dynamicConfig="true" 
      name="ehcacheManager" 
      > 
     .... 

    </ehcache> 

キャッシュのcontext.xml

 <bean id="cacheManager" 

     class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" scope="singleton"> 
       <property name="shared" value="true"/> 
       <property name="configLocation"> 
        <value>classpath:ehcache.xml</value> 
       </property> 
      </bean> 

私は残念ながら、私は削除できないことを、休止状態、ehcacheをする必要があり、古い依存ありません。これが問題だろうか?

<dependency> 
        <groupId>org.hibernate</groupId> 
        <artifactId>hibernate-ehcache</artifactId> 
        <version>3.5.0-Final</version> 
       </dependency> 

お勧めはありますか? ありがとうございました!

答えて

0

いくつかのソリューションはhere

ここで説明されている、あなたはehcache.xmlを提供したり、あなたがhere

編集を見ることができるようにそれ以外の場合はキャッシュ名を設定する必要があるかもしれません:ApplicationContextのは二回

をロードブレークポイントにヒットしたら、スタックトレースに上がって、なぜスプリングがコンテキストを2回読み込んでいるのかを知ることができます。

+0

お返事ありがとうございます。私は前にそれらをチェックした。私のehcache.xmlには名前があります。デバッグ私は、コンテキストが2回ロードされることがあることを知っています。わかりません。同じ名前で同じcacheManagerを登録しようとしています。 –

0

2つの可能性があります。

  1. 同じキャッチ名でsemeseverにインストールされている他の何らかのアプリケーション
  2. あなたが原因のContextLoaderListenerにサーバを起動するときに、アプリケーションは二回に展開します。したがって、web.xmlからContextLoaderListenerを削除してください。
関連する問題