[英]ehcache not working in Tomcat Docker image
我得到了一個Java應用程序來容器化。
該應用程序當前正在Tomcat8 JRE8 AWS Elasticbeanstalk實例上運行。
但是,該應用程序無法在我的Docker映像中部署,該映像是從Amazon Linux基本映像構建的,該映像具有通過RPM安裝的OpenJDK8和Tomcat8。
部署錯誤與Ehcache有關:
Error creating bean with name 'getEhcache' defined in *****: Invocation of init method failed; nested exception is net.sf.ehcache.CacheException: Error configuring from input stream. Initial cause was null:16: Element <cache> does not allow attribute "maxEntriesLocalHeap".
我了解,當Ehcache與所使用的Ehcache版本之間存在配置不匹配時,通常會出現此錯誤,即在版本2.10中引入了maxEntriesLocalHeap,如果版本2.10不可用,則會發生此錯誤。
我已經簽入了應用程序有效負載,並且可以使用正確的jar:
bash-4.2# pwd
/var/lib/tomcat8/webapps/ROOT/WEB-INF/lib
bash-4.2# ls -la ehcache-*
-rw-rw-r-- 1 root root 8914463 Jan 24 12:27 ehcache-2.10.2.jar
-rw-rw-r-- 1 root root 1006074 Jan 24 12:27 ehcache-core-2.4.5.jar
-rw-rw-r-- 1 root root 124522 Jan 24 12:27 ehcache-spring-annotations-1.2.0.jar
開發人員告訴我,該應用程序正在使用舊版本的Ehcache,但我看不到在原始Docker映像中怎么可能。 我認為這是由於運行時與Docker容器中的權限或文件系統訪問有關的某種原因而產生的虛假錯誤。
該應用程序隨附的ehcache.xml文件為:
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd"
updateCheck="true"
monitoring="autodetect"
dynamicConfig="true">
<diskStore path="java.io.tmpdir"/>
<cache name="messageCache"
maxEntriesLocalHeap="10000"
maxEntriesLocalDisk="1000"
eternal="false"
diskSpoolBufferSizeMB="20"
timeToIdleSeconds="43200" timeToLiveSeconds="43200"
memoryStoreEvictionPolicy="LFU"
transactionalMode="off">
<persistence strategy="localTempSwap"/>
</cache>
任何援助將不勝感激。
Ehcache在歷史過程中更改了jar的名稱。 您的沖突來自在類路徑上同時包含ehcache-core-2.4.5.jar
和ehcache-2.10.2.jar
。
最有可能首先拾取第一個,因此您會收到此無效屬性錯誤。 您很可能必須刪除ehcache-core-2.4.5.jar
但這可能需要增加其他依賴項,盡管Ehcache始終嘗試保持跨2.x行的向后兼容性。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.