GAE是否支持EHCache的后写操作?

时间:2015-04-26 08:37:09

标签: google-app-engine ehcache

我正在尝试创建一个使用ehcache存储和检索数据的Web应用程序。对我来说,以下配置对我来说很好。

<?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" 
       timeToIdleSeconds="120" 
       timeToLiveSeconds="120" 
       memoryStoreEvictionPolicy="LRU"> 
       <!-- <persistence strategy="none"/>  -->
    </defaultCache> 
    <cache name="st" 
      maxElementsInMemory="10000" 
      eternal="false" 
      timeToIdleSeconds="300" 
      timeToLiveSeconds="600" 
      memoryStoreEvictionPolicy="LRU" 
       />        
</ehcache>

但在引入Write-behind操作后,我收到以下错误。

配置:

<?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" 
       timeToIdleSeconds="120" 
       timeToLiveSeconds="120" 
       memoryStoreEvictionPolicy="LRU"> 
       <!-- <persistence strategy="none"/>  -->
    </defaultCache> 
    <cache name="st" 
      maxElementsInMemory="10000" 
      eternal="false" 
      timeToIdleSeconds="300" 
      timeToLiveSeconds="600" 
      memoryStoreEvictionPolicy="LRU" 
       > 
       <!-- <persistence strategy="none"/>  -->
            <cacheWriter writeMode="write-behind" maxWriteDelay="8" rateLimitPerSecond="5"
      writeCoalescing="true" writeBatching="true" writeBatchSize="20"
      retryAttempts="2" retryAttemptDelaySeconds="2">
           <cacheWriterFactory class="com.gowtham.st.shared.STWriterFactory" />
        </cacheWriter>
       </cache>
</ehcache>

错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sT' defined in file [/base/data/home/apps/s~google-test-40392/1.383872259417297841/WEB-INF/classes/com/gowtham/st/server/ST.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.gowtham.st.server.ST]: Constructor threw exception; nested exception is java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "modifyThreadGroup")

还有其他方法可以达到这个目的吗?

1 个答案:

答案 0 :(得分:1)

由于Ehcache后写直接使用线程,因此您无法使其在开箱即用的GAE上运行。需要开发来抽象线程创建,然后提供GAE集成模块。