【发布时间】:2017-06-27 20:55:36
【问题描述】:
我已经获得了一个用于容器化的 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 版本不匹配,即 maxEntriesLocalHeap 是在 2.10 版本中引入的,如果 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>
任何帮助将不胜感激。
【问题讨论】:
标签: java tomcat docker amazon-elastic-beanstalk ehcache