我是App Engine 1.8.5及其默认的核心数据存储版本。我正在使用具有GAE插件的本地Eclipse安装程序。
它已在我的本地计算机上成功地用于所有数据存储和检索。它已成功部署在Google App引擎服务器中。没有数据存储关系的URL可以正常工作,没有任何问题。
问题在于服务器中的数据存储检索。我正在使用GAE datanuclues引擎将JPA api用于数据存储。
问题是,当我从数据存储中检索数据时,它在服务器中抛出PESSIMISTIC_READ错误,但在本地计算机上却没有。我被卡住了,无法继续。
我已经粘贴了堆栈trace,persistence.xml和EMF.java文件供您参考。请帮助。
Caused by: java.lang.NoSuchFieldError: PESSIMISTIC_READ
at org.datanucleus.api.jpa.JPAQuery.getResultList(JPAQuery.java:171)
at com.ideafolks.codelist.datastore.dao.SectorDAO.getAllSector(SectorDAO.java:122)
at com.ideafolks.codelist.restful.SectorService.getAllSector(SectorService.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:45)
persistence.xml
<persistence-unit name="transactions-optional">
<provider>org.datanucleus.api.jpa.PersistenceProviderImpl</provider>
<class>com.ideafolks.codelist.datastore.tables.Sector</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="datanucleus.NontransactionalRead" value="true" />
<property name="datanucleus.NontransactionalWrite" value="true" />
<property name="datanucleus.ConnectionURL" value="appengine" />
<property name="datanucleus.singletonEMFForName" value="true" /> <!--
<property name="datanucleus.appengine.datastoreReadConsistency" value="EVENTUAL" /> -->
</properties>
</persistence-unit>
EMF.java
public final class EMF {
private static final EntityManagerFactory emfInstance = Persistence
.createEntityManagerFactory("transactions-optional");
private EMF() {
}
public static EntityManagerFactory get() {
return emfInstance;
}
}
最佳答案
您可能已将persistence-api-1.0.jar添加到您的类路径中。 geronimo-jpa_2.0_spec-1.0.jar具有JPA API的较新版本(LockModeType具有PESSIMISTIC_READ字段),因此您只需删除persistence-api-1.0.jar即可正常工作。您的应用在本地运行,因为您可能在类路径上有更高的GAE容器。