Google app engine GAE上的EHCache CacheManager初始化错误

Google app engine GAE上的EHCache CacheManager初始化错误,google-app-engine,ehcache,Google App Engine,Ehcache,我在GoogleAppEngineV1.7.0中以编程方式使用Ehcache2.6.0(没有EHCache.xml) 当我使用以下命令实例化CacheManager时: CacheManager cacheManager = CacheManager.create(); 我得到一个错误: Caused by: java.lang.RuntimeException: java.security.AccessControlException: access denied (java.lang.Ru

我在GoogleAppEngineV1.7.0中以编程方式使用Ehcache2.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)
在监控关闭的情况下:

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)
原因:java.lang.NoClassDefFoundError:无法初始化类net.sf.ehcache.util.lang.VicariousThreadLocal
位于net.sf.ehcache.TransactionController。(TransactionController.java:43)
位于net.sf.ehcache.CacheManager.doInit(CacheManager.java:433)
位于net.sf.ehcache.CacheManager.init(CacheManager.java:374)

如何解决这个问题?

AppEngine是一个分布式系统,其中请求由多个前端实例自动处理。在这种设置中,您不能在前端实例上使用缓存实现(EHCache),因为您将有多个EHCache实例在运行,写入一个EHCache不会反映在其他EHCache上


相反,您应该使用AppEngine自己的系统。

AppEngine是一个分布式系统,其中请求由多个前端实例自动处理。在这种设置中,您不能在前端实例上使用缓存实现(EHCache),因为您将有多个EHCache实例在运行,写入一个EHCache不会反映在其他EHCache上


相反,您应该使用AppEngine自己的。

在我看来,Ehcache v2.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>

在我看来,Ehcache v2.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>


但是EHCache提供了GAE支持,请参见OK,在本例中,EHCache似乎封装了GAE缓存。但您需要正确配置它:“兼容性Ehcache是兼容的,可以与Google App Engine配合使用。Google App Engine提供了一个受限的运行时,它限制了网络、线程和文件系统访问。”。网络限制意味着它不会被分发。如果我错了,请纠正我!!但是EHCache提供了GAE支持,请参阅OK,在本例中,EHCache似乎封装了GAE缓存。但您需要正确配置它:“兼容性Ehcache是兼容的,可以与Google App Engine配合使用。Google App Engine提供了一个受限的运行时,它限制了网络、线程和文件系统访问。”。网络限制意味着它不会被分发。如果我错了,请纠正我!!