DataNucleus:没有可用的类型为“appengine”的StoreManager

时间:2014-04-21 02:03:56

标签: google-app-engine jpa datanucleus

我正在尝试使用DataNucleus使用JPA设置AppEngine实例。但是在加载持久性单元时,我在运行时收到以下错误:

[INFO] Caused by: java.lang.ExceptionInInitializerError
[INFO]  at org.apache.jsp.guestbook_jsp._jspService(guestbook_jsp.java:123)
[INFO]  ... 45 more
[INFO] Caused by: org.datanucleus.exceptions.NucleusUserException: There is no available StoreManager of type "appengine". Make sure that you have put the relevant DataNucleus store plugin in your CLASSPATH and if defini
ng a connection via JNDI or DataSource you also need to provide persistence property "datanucleus.storeManagerType"
[INFO]  at org.datanucleus.NucleusContext.createStoreManagerForProperties(NucleusContext.java:1276)
[INFO]  at org.datanucleus.NucleusContext.initialise(NucleusContext.java:357)
[INFO]  at org.datanucleus.api.jpa.JPAEntityManagerFactory.initialiseNucleusContext(JPAEntityManagerFactory.java:816)
[INFO]  at org.datanucleus.api.jpa.JPAEntityManagerFactory.initialise(JPAEntityManagerFactory.java:437)
[INFO]  at org.datanucleus.api.jpa.JPAEntityManagerFactory.<init>(JPAEntityManagerFactory.java:396)
[INFO]  at org.datanucleus.api.jpa.PersistenceProviderImpl.createEntityManagerFactory(PersistenceProviderImpl.java:116)
[INFO]  at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
[INFO]  at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)

本地和AppEngine部署都会发生此错误。

我应该为datanucleus.ConnectionURL属性提供什么价值不是AppEngine? NB我无法找到任何解释这个值在AppEngine环境中实际含义的doco。链接到什么意思?

我的意思是在某个地方定义StoreManager吗?

我错过了一些图书馆吗?如果是这样的话?

我的persistence.xml是:

<persistence-unit name="main">
    <provider>org.datanucleus.api.jpa.PersistenceProviderImpl</provider>

    <mapping-file>/META-INF/user.xml</mapping-file>

    <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"/>
    </properties>
</persistence-unit>

我的POM中的依赖项是:                           com.google.appengine             应用服务引擎的API-1.0-SDK             $ {} appengine.target.version         

    ..

    <!-- Persistence APIs -->
    <dependency> <!-- why do I need this if I am using JPA? -->
        <groupId>javax.jdo</groupId>
        <artifactId>jdo-api</artifactId>
        <version>3.0.1</version>
    </dependency>
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>javax.persistence</artifactId>
        <version>2.1.0</version>
    </dependency>
    <dependency>
        <groupId>org.datanucleus</groupId>
        <artifactId>datanucleus-core</artifactId>
        <version>[3.2.0, 3.2.99)</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.datanucleus</groupId>
        <artifactId>datanucleus-api-jpa</artifactId>
        <version>[3.3.0-release, 3.3.99)</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.datanucleus</groupId>
        <artifactId>datanucleus-rdbms</artifactId>
        <version>[3.2.0, 3.2.99)</version>
        <scope>runtime</scope>
    </dependency>
</dependencies>

datanucleus-plugin是:

    <plugin>
        <groupId>org.datanucleus</groupId>
        <artifactId>datanucleus-maven-plugin</artifactId>
        <version>3.3.0-release</version>
        <configuration>
            <api>JPA</api>
            <persistenceUnitName>main</persistenceUnitName>
            <verbose>true</verbose>
        </configuration>
        <executions>
            <execution>
                <phase>process-classes</phase>
                <goals>
                    <goal>enhance</goal>
                </goals>
            </execution>
        </executions>
        <dependencies>
            <dependency>
                <groupId>org.datanucleus</groupId>
                <artifactId>datanucleus-core</artifactId>
                <version>[3.2.0, 3.2.99)</version>
            </dependency>
            <dependency>
                <groupId>org.datanucleus</groupId>
                <artifactId>datanucleus-api-jpa</artifactId>
                <version>[3.3.0-release, 3.3.99)</version>
            </dependency>
        </dependencies>
    </plugin>

1 个答案:

答案 0 :(得分:3)

如果你坚持使用RDBMS(而不是GAE / Datastore),那么可以按照他们的文档来获取URL http://www.datanucleus.org/products/accessplatform/datastores/rdbms.html

如果您坚持使用GAE / Datastore,则从CLASSPATH中删除“datanucleus-rdbms”并添加 com.google.appengine.orm“datanucleus-appengine”。并注意https://code.google.com/p/datanucleus-appengine/wiki/Compatibility上的兼容性文档,该文档表示除非您使用来自Google SVN的手动构建(未发布)版本的datanucleus-appengine,否则不能使用DataNucleus 3.2 / 3.3