0

I've been going working through some jpa on google app engine tutorials. In all the tutorials, the entity classes are not specified in persistence.xml. But my local environment throws a NoPersistenceInformationException. The class "de.vogella.gae.java.todo.model.Todo" is required to be persistable yet no Meta-Data/Annotations can be found for this class. Please check that the Meta-Data/annotations is defined in a valid file location.

If I specify the entity classes in persistence.xml, the problem goes away.

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.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_1_0.xsd">
<persistence-unit name="transactions-optional">
<provider>org.datanucleus.api.jpa.PersistenceProviderImpl</provider>
<class>de.vogella.gae.java.todo.model.Todo/class>
<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.datastoreEnableXGTransactions" value="true"/>
</properties>

can somebody explain to me why I need to do this in my case? None of the JPA on GAE tutorials need to do this. One difference is that I use the google appengine maven plugin and not the eclipse plugin.

Here's my pom file

http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>

<groupId>de.vogella.gae.java.todo</groupId>
<artifactId>todo</artifactId>

<pluginRepositories>
    <pluginRepository>
        <id>google-snapshots</id>
        <name>Google Snapshots</name>
        <url>https://oss.sonatype.org/content/repositories/google-snapshots/</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
        <releases>
            <enabled>false</enabled>
        </releases>
    </pluginRepository>
</pluginRepositories>

<properties>
    <appengine.app.version>1</appengine.app.version>
    <appengine.target.version>1.7.4</appengine.target.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <!-- Compile/runtime dependencies -->
    <dependency>
        <groupId>com.google.appengine</groupId>
        <artifactId>appengine-api-1.0-sdk</artifactId>
        <version>${appengine.target.version}</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>

    <!-- JPA dependencies -->
    <dependency>
        <groupId>com.google.appengine.orm</groupId>
        <artifactId>datanucleus-appengine</artifactId>
        <version>2.0.1.1</version>
    </dependency>
    <dependency>
        <groupId>javax.jdo</groupId>
        <artifactId>jdo-api</artifactId>
        <version>[3.0, 4.0)</version>
    </dependency>
    <dependency>
        <groupId>org.apache.geronimo.specs</groupId>
        <artifactId>geronimo-jpa_2.0_spec</artifactId>
        <version>1.0</version>
    </dependency>
    <dependency>
        <groupId>org.datanucleus</groupId>
        <artifactId>datanucleus-core</artifactId>
        <version>[3.0, 3.0.99)</version>
    </dependency>
    <dependency>
        <groupId>org.datanucleus</groupId>
        <artifactId>datanucleus-api-jpa</artifactId>
        <version>[3.0, 3.0.99)</version>
    </dependency>
    <dependency>
        <groupId>org.datanucleus</groupId>
        <artifactId>datanucleus-jpa-query</artifactId>
        <version>3.0.2</version>
    </dependency>

    <!-- Test Dependencies -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.10</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-all</artifactId>
        <version>1.9.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.google.appengine</groupId>
        <artifactId>appengine-testing</artifactId>
        <version>${appengine.target.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.google.appengine</groupId>
        <artifactId>appengine-api-stubs</artifactId>
        <version>${appengine.target.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-jaxrs</artifactId>
        <version>2.3.5.Final</version>
    </dependency>
    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-jackson-provider</artifactId>
        <version>2.3.5.Final</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <version>2.5.1</version>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <!-- compilerArguments>
                    <processor>org.datanucleus.jpa.query.JPACriteriaProcessor</processor>
                </compilerArguments -->                 
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <archiveClasses>true</archiveClasses>
                <webResources>
                    <!-- in order to interpolate version from pom into appengine-web.xml -->
                    <resource>
                        <directory>${basedir}/src/main/webapp/WEB-INF</directory>
                        <filtering>true</filtering>
                        <targetPath>WEB-INF</targetPath>
                    </resource>
                </webResources>
            </configuration>
        </plugin>
        <plugin>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-maven-plugin</artifactId>
            <version>1.7.5-SNAPSHOT</version>
            <configuration>
                <jvmFlags>
                    <jvmFlag>-Xdebug</jvmFlag>
                    <jvmFlag>-Xrunjdwp:transport=dt_socket,address=1044,server=y,suspend=n</jvmFlag>
                    <jvmFlag>-Ddatastore.default_high_rep_job_policy_unapplied_job_pct=20</jvmFlag>
                </jvmFlags>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.datanucleus</groupId>
            <artifactId>maven-datanucleus-plugin</artifactId>
            <version>3.0.2</version>
            <configuration>
                <api>JPA</api>
                <persistenceUnitName>transactions-optional</persistenceUnitName>
                <!-- log4jConfiguration>${basedir}/log4j.properties</log4jConfiguration -->
                <verbose>true</verbose>
            </configuration>
            <executions>
                <execution>
                    <phase>process-classes</phase>
                    <goals>
                        <goal>enhance</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

And here's the tutorial I am going though http://www.vogella.com/articles/GoogleAppEngineJava/article.html

Ron
  • 191
  • 1
  • 7

1 Answers1

1

i guess my googling skills are weak, as i didn't find my answer before asking...

but this question has already been asked on stackoverflow...

class elements in persistence.xml

Community
  • 1
  • 1
Ron
  • 191
  • 1
  • 7