私はappengineを初めて使用し、appengineバージョン1.8.7(1.8.6でも起こります)を使用し、プロジェクトにmavenを追加しようとしています。
エンティティを永続化すると、ログは次のようになります。
[INFO] nov 07, 2013 5:38:33 PM com.google.appengine.api.datastore.dev.LocalDatastoreService init
[INFO] INFO: Local Datastore initialized:
[INFO] Type: High Replication
[INFO] Storage: D:\Projects\JEE\myapp\tmp\local_db.bin
[INFO] nov 07, 2013 5:38:33 PM com.google.appengine.api.datastore.dev.LocalDatastoreService load
[INFO] INFO: The backing store, D:\Projects\JEE\myapp\tmp\local_db.bin, does not exist. It will be created.
私の問題は、local_db.bin が作成されていないことです。たとえば、永続化されたエンティティを検索しようとすると、エラーが表示されます。
[INFO] java.lang.IllegalArgumentException: Type com.harriague.myapp.dao.entities.Travel is not a known entity type
[INFO] at org.datanucleus.api.jpa.metamodel.MetamodelImpl.entity(MetamodelImpl.java:193)
...
これは私のエンティティクラスです:
package com.harriague.myapp.dao.entities;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Column;
import com.google.appengine.api.datastore.Key;
@Entity(name = "Travel")
public class Travel {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Key travelId;
@Column(name = "name")
private String name;
public Travel() {
}
public Key getTravelId() {
return travelId;
}
public void setTravelId(Key travelId) {
this.travelId = travelId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
mi pom.xml は次のとおりです。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<groupId>com.harriague</groupId>
<artifactId>myapp</artifactId>
<properties>
<appengine.app.version>1</appengine.app.version>
<appengine.target.version>1.8.7</appengine.target.version>
<datanucleus-core.version>3.1.3</datanucleus-core.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>com.google.appengine</groupId>
<artifactId>appengine-endpoints</artifactId>
<version>${appengine.target.version}</version>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-labs</artifactId>
<version>${appengine.target.version}</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>4.0</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>
<!-- JSON -->
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<!-- Test Dependencies -->
<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>
<!-- Spring framework -->
<!--
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.6</version>
</dependency>
-->
<!-- Javax persistence -->
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>${datanucleus-core.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-api-jpa</artifactId>
<version>3.1.3</version>
</dependency>
<dependency>
<groupId>com.google.appengine.orm</groupId>
<artifactId>datanucleus-appengine</artifactId>
<version>2.1.2</version>
<!-- Need to exclude the enhancer since it interfere with the enhancer plugin. -->
<exclusions>
<exclusion>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-enhancer</artifactId>
</exclusion>
</exclusions>
</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>
</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>
<!--
<resource>
<directory>${basedir}/src/main/resources</directory>
</resource>
-->
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.target.version}</version>
<configuration>
<enableJarClasses>false</enableJarClasses>
<!--<jvmFlags>
<jvmFlag>-Ddatastore.backing_store=${basedir}\local_db.bin</jvmFlag>
</jvmFlags>
-->
<jvmFlags>
<jvmFlag>-Dappengine.generated.dir=${basedir}/tmp</jvmFlag>
</jvmFlags>
<!--
<jvmFlags>
<jvmFlag>-Xdebug</jvmFlag>
<jvmFlag>-Xrunjdwp:transport=dt_socket,address=8080,server=y,suspend=y</jvmFlag>
</jvmFlags>
-->
<disableUpdateCheck>true</disableUpdateCheck>
</configuration>
</plugin>
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>maven-datanucleus-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<api>JPA</api>
<fork>false</fork>
<persistenceUnitName>transactions-optional</persistenceUnitName>
<verbose>true</verbose>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
さらに、このプロジェクトが appengine Eclipse プラグインを使用して作成されている場合、このようなことは起こらず、私のコードは正常に動作します。
前もって感謝します