我用 JSF(Primefaces)和 JPA 创建了一个应用程序,我正在尝试将它部署在 GAE 上。首先,我尝试使用本地应用引擎 sdk。尝试将 JPA 与 CloudSQL 一起使用时遇到问题。我正在按照有关如何在此处使用 Eclipse 进行操作的说明进行操作:
https://developers.google.com/eclipse/docs/cloudsql-jpatools
但是我收到以下错误:
Caused by: javax.persistence.PersistenceException: Provider error. Provider: org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider
at javax.persistence.Persistence.createFactory(Persistence.java:176)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:112)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:66)
at org.Handlers.EMFService.<clinit>(EMFService.java:8)
... 51 more
Caused by: java.lang.NullPointerException
at org.datanucleus.jpa.EntityManagerFactoryImpl.initialisePMF(EntityManagerFactoryImpl.java:452)
at org.datanucleus.jpa.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:355)
at org.datanucleus.store.appengine.jpa.DatastoreEntityManagerFactory.<init>(DatastoreEntityManagerFactory.java:63)
at org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider.createEntityManagerFactory(DatastorePersistenceProvider.java:35)
at javax.persistence.Persistence.createFactory(Persistence.java:172)
... 54 more
更重要的是我认为datanucleus是用来访问App引擎Datastore的。但是我正在尝试连接到关系云 sql 数据库(它已启动并正在运行)。所以我不明白数据核与此有什么关系。
我正在使用 Eclipselink 来实现 GAE 以下指南中提出的 JPA 规范: https ://developers.google.com/eclipse/docs/cloudsql-jpatools
下面还可以看到persistence.xml:
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="googleeclipselink"
transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>org.entities.Department</class>
<class>org.entities.Employee</class>
<class>org.entities.Partner</class>
<class>org.entities.Project</class>
<class>org.entities.User</class>
<properties>
<!-- <property name="datanucleus.NontransactionalRead" value="true" />
<property name="datanucleus.NontransactionalWrite" value="true" /> <property
name="datanucleus.ConnectionURL" value="appengine" /> -->
<property name="javax.persistence.jdbc.driver"
value="com.google.appengine.api.rdbms.AppEngineDriver" />
<property name="javax.persistence.jdbc.url"
value="jdbc:google:rdbms://fotisgonidisseerc:googlecloudsql/researchprojects" />
<property name="javax.persistence.jdbc.user" value="" />
<property name="javax.persistence.jdbc.password" value="" />
</properties>
</persistence-unit>
</persistence>
任何人都可以给我一个提示如何解决它?