Google AppEngine中的Datanucleus JPA 2 2级缓存 [英] Datanucleus JPA 2 Level 2 cache in Google AppEngine

查看:124
本文介绍了Google AppEngine中的Datanucleus JPA 2 2级缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在以下配置中,我的Datanucleus JPA 2 2级缓存未使用Google App Engine Memcache服务时,我缺少什么?我正在使用GAE 1.7.2 SDK。

What am I missing in the following configuration that my Datanucleus JPA 2 Level 2 cache is not using Google App Engine Memcache service? I am using the GAE 1.7.2 SDK.

在persistence.xml中:

In the persistence.xml:

<persistence-unit name="transactions-optional">
    <provider>org.datanucleus.api.jpa.PersistenceProviderImpl</provider>
    <properties>
        <property name="datanucleus.NontransactionalRead" value="true"/>
        <property name="datanucleus.NontransactionalWrite" value="true"/>
        <property name="datanucleus.ConnectionURL" value="appengine"/>
        <property name="datanucleus.appengine.datastoreReadConsistency" value="EVENTUAL" />
        <property name="javax.persistence.query.timeout" value="5000" />
        <property name="datanucleus.datastoreWriteTimeout" value="10000" />
        <property name="datanucleus.singletonEMFForName" value="true"/>
        <property name="datanucleus.cache.level2.cacheName" value="someName"/>
        <property name="datanucleus.cache.level2.type" value="javax.cache"/>
    </properties>
</persistence-unit>

实体注释包含:

@Entity
@Cacheable(true)

我的WEB- INF / lib看起来像这样:

My WEB-INF/lib looks like this:

-rw-r--r--   1 501  20    27M Oct  3 16:13 appengine-api-1.0-sdk-1.7.2.jar
-rw-r--r--   1 501  20   3.3M Oct  3 16:13 appengine-api-labs.jar
-rw-r--r--   1 501  20   5.0M Oct  3 16:13 appengine-endpoints.jar
-rw-r--r--   1 501  20   6.8K Oct  3 16:13 appengine-jsr107cache-1.7.2.jar
-rw-r--r--   1 501  20    45K Oct  3 16:13 asm-4.0.jar
-rw-r--r--   1 501  20   309K Oct  3 16:13 datanucleus-api-jdo-3.1.0-m3.jar
-rw-r--r--   1 501  20   246K Oct  3 16:13 datanucleus-api-jpa-3.1.0-m3.jar
-rw-r--r--   1 501  20   331K Oct  3 16:13 datanucleus-appengine-2.1.0-final.jar
-rw-r--r--   1 501  20   1.6M Oct  3 16:13 datanucleus-core-3.1.0-m5.jar
-rw-r--r--   1 501  20   112K Oct  3 16:13 geronimo-jpa_2.0_spec-1.0.jar
-rw-r--r--   1 501  20   5.2M Oct  3 16:13 gwt-servlet.jar
-rw-r--r--   1 501  20   196K Oct  3 16:13 jdo-api-3.0.1.jar
-rw-r--r--   1 501  20   7.9K Oct  3 16:13 jsr107cache-1.1.jar
-rw-r--r--   1 501  20    15K Oct  3 16:13 jta-1.1.jar

在WEB-INF / lib目录中,运行:

In the WEB-INF/lib directory, running:

for i in *.jar; do echo $i; jar -tf $i | grep Level2; done

收益:

appengine-api-1.0-sdk-1.7.2.jar
appengine-api-labs.jar
appengine-endpoints.jar
appengine-jsr107cache-1.7.2.jar
asm-4.0.jar
datanucleus-api-jdo-3.1.0-m3.jar
datanucleus-api-jpa-3.1.0-m3.jar
datanucleus-appengine-2.1.0-final.jar
datanucleus-core-3.1.0-m5.jar
org/datanucleus/cache/WeakLevel2Cache.class
org/datanucleus/cache/Level2Cache$PinnedClass.class
org/datanucleus/cache/AbstractLevel2Cache.class
org/datanucleus/cache/SoftLevel2Cache.class
org/datanucleus/cache/Level2Cache.class
org/datanucleus/cache/NullLevel2Cache.class
org/datanucleus/cache/JavaxCacheLevel2Cache.class
geronimo-jpa_2.0_spec-1.0.jar
gwt-servlet.jar
jdo-api-3.0.1.jar
jsr107cache-1.1.jar
jta-1.1.jar

这表明org.datanucleus.cache.JavaxCacheLevel2Cache存在于datanucleus-core-3.1.0-m5.jar中。但是,当我尝试访问在启用此缓存之前已保留的实体时,在服务器端出现以下错误。

which shows that org.datanucleus.cache.JavaxCacheLevel2Cache is present in datanucleus-core-3.1.0-m5.jar. Yet, when I try to access entities that have been persisted before this cache was enabled, I get the following error on the server side.

org.datanucleus.exceptions.NucleusUserException: Level 2 Cache "javax.cache" is registered to use class "org.datanucleus.cache.JavaxCacheLevel2Cache" yet this is not found. Please check your CLASSPATH and plugin specification.

在异常堆栈跟踪中,我发现:

Further down the exception stack trace, I find:

Caused by: java.lang.NoClassDefFoundError: javax/cache/Caching
    at org.datanucleus.cache.JavaxCacheLevel2Cache.<init>(JavaxCacheLevel2Cache.java:63)

现在,这很清楚,但是在哪里可以找到此javax.cache.Caching?我需要在类路径中包括哪个JAR?粗略的Google搜索不会立即回答我的问题。

Now, that is clear but where can I find this javax.cache.Caching? Which JAR should I need to include in the classpath? A cursory Google search does not immediately answer my question.

谢谢。

推荐答案

Google memcached使用的旧版本将成为标准的 javax.cache。 DataNucleus 3.0仅支持此旧版本(具有属性)。 DataNucleus 3.1同时支持旧版本的javax.cache和最新版本的 。要使用DN 3.1使用旧版本(即GAE memcached),您需要将属性 datanucleus.cache.level2.type 设置为 jcache 。请参阅 http://www.datanucleus.org/products/accessplatform_3_1/jpa/ cache.html#jcache

Google "memcached" uses an old version of what will become the standard "javax.cache". DataNucleus 3.0 supports only this old version (with properties as you have). DataNucleus 3.1 supports both the old version of javax.cache and the most recent. To use the old version (i.e GAE memcached) with DN 3.1 you need to set the property datanucleus.cache.level2.type to jcache. See http://www.datanucleus.org/products/accessplatform_3_1/jpa/cache.html#jcache

为什么使用DataNucleus版本3.1.0-m3 / m5,自那时以来我不知道何时有很多版本!

Why you're using DataNucleus version 3.1.0-m3/m5 I've no idea when there are many releases since then!

这篇关于Google AppEngine中的Datanucleus JPA 2 2级缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆