我在Google App Engine v1.7.0中以编程方式使用EHCache 2.6.0 (没有ehcache.xml)。
当我使用以下命令实例化CacheManager时:
CacheManager cacheManager = CacheManager.create();我收到错误:
Caused by: java.lang.RuntimeException: java.security.AccessControlException: access denied (java.lang.RuntimePermission accessDeclaredMembers)
at java.util.concurrent.atomic.AtomicReferenceFieldUpdater$AtomicReferenceFieldUpdaterImpl.<init>(AtomicReferenceFieldUpdater.java:217)
at java.util.concurrent.atomic.AtomicRefe...(length 9029)我试过了:
CacheManager cacheManager = new CacheManager();关闭监控后:
Configuration configuration = new Configuration();
configuration.setMonitoring(Configuration.Monitoring.OFF.name());
configuration.setUpdateCheck(false);
CacheManager cacheManager = new CacheManager(configuration);对于这两种情况,我都得到了以下错误:
Caused by: java.lang.NoClassDefFoundError: Could not initialize class net.sf.ehcache.util.lang.VicariousThreadLocal
at net.sf.ehcache.TransactionController.<init>(TransactionController.java:43)
at net.sf.ehcache.CacheManager.doInit(CacheManager.java:433)
at net.sf.ehcache.CacheManager.init(CacheManager.java:374)如何解决这个问题?
发布于 2012-09-17 00:32:48
在我看来,EhcacheV2.6与当前的AppEngine不兼容。我必须切换到以前版本的ehcache才能运行它。经过长时间的尝试和错误,2.4.7版似乎是稳定的。显然,ehcache提供的配置不起作用。下面是我必须如何配置它:
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd" >
<cacheManagerEventListenerFactory class="" properties=""/>
<defaultCache
maxElementsInMemory="10000"
eternal="false"
overflowToDisk="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
memoryStoreEvictionPolicy="LRU">
</defaultCache>
<!--Example sample cache-->
<cache name="sid"
maxElementsInMemory="100"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="300"
memoryStoreEvictionPolicy="LFU"
/>
</ehcache>发布于 2012-09-07 16:14:58
AppEngine是一个分布式系统,请求由多个前端实例自动处理。在这样的设置中,您不能在前端实例上使用缓存实现( EHCache ),因为您将有多个EHCache实例在运行,写入一个EHCache不会反映到其他EHCaches上。
相反,您应该使用AppEngine自己的memcache service。
https://stackoverflow.com/questions/12313173
复制相似问题