2017-02-09 142 views
0

我已經給了一個Java應用程序來containerise。ehcache在Tomcat中不工作Docker鏡像

該應用程序當前正在Tomcat8 JRE8 AWS Elasticbeanstalk實例上運行。

但是,應用程序無法部署到我的Docker映像中,該映像是通過RPM安裝的OpenJDK8和Tomcat8的Amazon Linux基礎映像構建的。

的部署錯誤涉及到的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版本之間的配置不匹配這個錯誤通常出現,即maxEntriesLocalHeap在2.10版本推出,如果版本2.10不可用,則會發生此錯誤。

我已經在應用有效載荷檢查,正確的罐子可用:

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> 

任何援助將不勝感激。

回答

1

Ehcache在歷史過程中改變了罐子的名稱。您的衝突來自您的類路徑中有ehcache-core-2.4.5.jarehcache-2.10.2.jar

最有可能的第一個被挑選出來,因此你得到這個無效的屬性錯誤。儘管Ehcache總是試圖保持2.x行的向後兼容性,但您很可能不得不刪除ehcache-core-2.4.5.jar,但可能需要衝突其他依賴項。

+0

答案是正確的。作爲一個附註,如果我是你,我會把'updateCheck'設爲false。 – Henri

+0

有道理,但我很好奇爲什麼這不是ElasticBeanstalk實例中的問題,而是Docker容器中的一個問題。 –