谷歌应用引擎和JPA与Eclipse插件

时间:2012-11-26 15:31:25

标签: google-app-engine jpa datanucleus google-plugin-eclipse

我用JSF(Primefaces)和JPA创建了一个应用程序,我试图在GAE上部署它。首先,我尝试使用本地应用程序引擎sdk。尝试在CloudSQL中使用JPA时遇到问题。我在这里按照说明如何使用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引擎数据存储区。但是我试图连接到关系云sql数据库(它启动并运行)。所以我不明白数据核与此有什么关系。

我正在使用Eclipselink来实现GAA的以下指南所提出的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>

任何人都可以给我一些如何解决它的提示?

1 个答案:

答案 0 :(得分:1)

在这个问题上花了一些时间后,我发现我必须从WEB-INF / lib中删除DataNucleus库。我还需要在classpath中添加EclipseLink库。 这是因为我使用EclipseLink作为JPA实现。因此DataNucleus导致冲突,因此需要删除。 我想Eclipse的谷歌插件会自动执行此操作,但显然有时会失败。