带有DataNucleus的Google App Engine显示无法检测到错误消息

时间:2014-04-05 02:53:41

标签: google-app-engine jdo datanucleus

我正在使用带有DataNucleus(JDO)的Google App Engine 1.9.2。当我尝试将对象写入数据存储区时,我总是看到以下错误(“严重:无法检测...... ”)第一次写入操作完成。后续写入不显示此错误。此外,我只在以开发模式运行时才会看到此错误。当我将我的应用程序上传到生产时,没有错误。但是在开发过程中看到这个错误是非常令人沮丧的 - 我花了几天时间才发现究竟发生了什么,最后它只显示在开发模式中。需要做些什么来避免出现此SEVERE错误消息?

家长班:

import javax.jdo.annotations.Inheritance;
import javax.jdo.annotations.InheritanceStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;

@PersistenceCapable
@Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE)
public abstract class Recipe {
    @Persistent
    private int prepTime;

    public Recipe() {
        prepTime = 99;
    }
}

儿童班:

import javax.jdo.annotations.Inheritance;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;

@PersistenceCapable
@Inheritance(customStrategy = "complete-table")
public class NewEntree extends Recipe {
    @Persistent
    private int noOfIngredients;

    public NewEntree() {
        noOfIngredients = 22;
    }
}

厨师班:

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.Inheritance;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable
@Inheritance(customStrategy = "complete-table")
public class Chef {
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;

    @Persistent(dependent = "true")
    private NewEntree favoriteRecipe;

    public Chef() {
    }

    public void setKey(Key k) {
        this.key = k;
    }

    public void setRecipe(NewEntree ne) {
        favoriteRecipe = ne;
   }
}

执行写操作的代码:

PersistenceManagerFactory pmfInstance = 
        JDOHelper.getPersistenceManagerFactory("transactions-optional");
PersistenceManager pm = pmfInstance.getPersistenceManager();
try {
    log.info("enter create");
    NewEntree myEntree = new NewEntree();
    Key key = KeyFactory.createKey(Chef.class.getSimpleName(), 
            "TheChef");
    Chef myChef = new Chef();
    myChef.setKey(key);
    myChef.setRecipe(myEntree);
    pm.makePersistent(myChef);
    log.info("create done");
} finally {
    pmfInstance.close();
}

日志中出现的错误:

    Apr 04, 2014 6:22:01 PM com.google.appengine.tools.development.agent.impl.Transformer transform
    SEVERE: Unable to instrument com.xxx.NewEntree. Security restrictions may not be entirely emulated.
    java.lang.ArrayIndexOutOfBoundsException: 2
            at com.google.appengine.repackaged.org.objectweb.asm.ClassReader.readFrameType(ClassReader.java:1835)
            at com.google.appengine.repackaged.org.objectweb.asm.ClassReader.readFrame(ClassReader.java:1794)    ...
Apr 04, 2014 6:22:01 PM com.google.appengine.tools.development.agent.impl.Transformer transform
SEVERE: Unable to instrument com.xxx.Recipe. Security restrictions may not be entirely emulated.
java.lang.ArrayIndexOutOfBoundsException: 92
        at com.google.appengine.repackaged.org.objectweb.asm.ClassReader.readLabel(ClassReader.java:1880)
...
Apr 04, 2014 6:22:02 PM com.google.appengine.tools.development.agent.impl.Transformer transform
SEVERE: Unable to instrument com.xxx.Chef. Security restrictions may not be entirely emulated.
java.lang.ArrayIndexOutOfBoundsException: 133
        at com.google.appengine.repackaged.org.objectweb.asm.ClassReader.readLabel(ClassReader.java:1880)

相关POM:

<dependency>
    <groupId>javax.jdo</groupId>
    <artifactId>jdo-api</artifactId>
    <version>3.0.1</version>
</dependency>
<dependency>
    <groupId>org.datanucleus</groupId>
    <artifactId>datanucleus-core</artifactId>
    <version>3.1.3</version>
</dependency>
<dependency>
    <groupId>com.google.appengine.orm</groupId>
    <artifactId>datanucleus-appengine</artifactId>
    <version>2.1.2</version>
</dependency>
<dependency>
    <groupId>org.datanucleus</groupId>
    <artifactId>datanucleus-api-jdo</artifactId>
    <version>3.1.3</version>
</dependency>

0 个答案:

没有答案