2009-11-26 138 views
9

應用程序啓動時出現以下警告。ehcache警告消息「找不到配置」

2009-05-13 09:19:41,171 WARN net.sf.ehcache.config.Configurator - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath:jar:file:/app/java/lib/ehcache-1.1.jar!/ehcache-failsafe.xml 

我發現encache代碼在以下網址.. ConfigurationFactory Code

應用程序試圖加載ehcache.xml中卻找不到該文件,然後將其加載的Ehcache-failsafe.xml.I想知道這是否導致應用程序出現任何問題?什麼是影響加載ehcache-failsafe.xml?

回答

10

加載ehcache-failsafe.xml本身不會導致問題;但它很可能不適合您的應用程序。

EhCache開發人員無法知道您打算緩存什麼;因此分配中包含的ehcache-failsafe.xml會嘗試提供某些「最低公分母」設置,這些設置在大多數情況下或多或少都可行。您會收到警告,提醒您指定更適合您特定需求的配置。

28

ehcache.xml應引入您的classpath,特別是WEB-INF/classes/。然後,您可以根據您的環境指定您的需求。

這是一個例子:

<?xml version="1.0" encoding="UTF-8"?> 

<ehcache> 
    <diskStore path="java.io.tmpdir"/> 

    <cache name="org.hibernate.cache.UpdateTimestampsCache" 
      maxElementsInMemory="50000" 
      eternal="true" 
      overflowToDisk="true"/> 

    <cache name="org.hibernate.cache.StandardQueryCache" 
      maxElementsInMemory="50000" 
      eternal="false" 
      timeToIdleSeconds="120" 
      timeToLiveSeconds="120" 
      overflowToDisk="true" 
      diskPersistent="false" 
       diskExpiryThreadIntervalSeconds="120" 
      memoryStoreEvictionPolicy="LRU" 
      /> 

    <defaultCache 
      maxElementsInMemory="50000" 
      eternal="false" 
      timeToIdleSeconds="120" 
      timeToLiveSeconds="120" 
      overflowToDisk="true" 
      diskPersistent="false" 
      diskExpiryThreadIntervalSeconds="120" 
      memoryStoreEvictionPolicy="LRU" 
      /> 

</ehcache> 

3年後,希望我的回答可以幫助別人。

+0

感謝您的時間,我已經離開這個無論如何,我會嘗試下次你的建議! – nayakam 2012-04-04 01:43:30

0

這個問題背後的原因是,你沒有足夠的內存來緩存數據,只需編輯tomcat的/bin/catalina.sh文件並根據需要增加內存。例如我已經增加了1024M的內存。 JAVA_OPTS="-Xms512M -Xmx1024M -XX:PermSize=1024M -XX:MaxPermSize=1024M"

0

如果您正在使用的Ehcache作爲Hibernate的變化的二級緩存提供商:hibernate.cache.provider_configuration_file_resource_path與net.sf.ehcache.configurationResourceName 的Ehcache將能夠找到您的配置即可。

+0

雖然這並不回答原來的問題。 OP詢問了故障安全xml的影響 – Dipto 2017-03-18 20:54:49