Google App Engine ClassNotPersistenceCapableException [英] Google App Engine ClassNotPersistenceCapableException

查看:140
本文介绍了Google App Engine ClassNotPersistenceCapableException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下类:

  import javax.jdo.annotations.IdGeneratorStrategy; 
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import com.google.appengine.api.datastore。*;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class PayPal_Message
{
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
私人长ID;
@Persistent
私人文本内容;
@Persistent
私人字符串时间;

public PayPal_Message(文本内容,字符串时间)
{
this.content = content;
this.time = time;
}

public Long getId(){return id; }
public Text getContent(){return content; }
public String getTime(){return time; }
public void setContent(Text content){this.content = content; }
public void setTime(String time){this.time = time; }
}

它曾经是一个包,并且工作正常,现在我把所有类都在默认包中,这导致了我这个错误:

org.datanucleus.jdo.exceptions.ClassNotPersistenceCapableException:类PayPal_Message不是持久化的。这意味着它或者没有被增强,或者文件的增强版本不在CLASSPATH中(或者被未增强版本隐藏),或者没有找到该类的元数据/注释。不可持久。这意味着它或者没有被增强,或者文件的增强版本不在CLASSPATH中(或者被未增强版本隐藏),或者没有找到该类的元数据。
NestedThrowables:
org.datanucleus.exceptions.ClassNotPersistableException:类PayPal_Message不可持久化。这意味着它或者没有被增强,或者文件的增强版本不在CLASSPATH中(或者被未增强版本隐藏),或者没有找到该类的元数据/注释。



我应该怎么做才能解决它? 解释方法

包不能被包中的类看到/可导入。



请尝试以下示例:

  public class Entity {} 

(因此不包括!)和

 包持久化; 

public class EntityManager {
public static void main(String ... args){
Entity entity = new Entity();
}
}

它有效吗?没有?你会如何导入它?这就是幕后发生的问题!


I have the following class :

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import com.google.appengine.api.datastore.*;

@PersistenceCapable(identityType=IdentityType.APPLICATION)
public class PayPal_Message
{
  @PrimaryKey
  @Persistent(valueStrategy=IdGeneratorStrategy.IDENTITY)
  private Long id;
  @Persistent
  private Text content;
  @Persistent
  private String time;

  public PayPal_Message(Text content,String time)
  {
    this.content=content;
    this.time=time;
  }

  public Long getId() { return id; }
  public Text getContent() { return content; }
  public String getTime() { return time; }
  public void setContent(Text content) { this.content=content; }
  public void setTime(String time) { this.time=time; }
}

It used to be in a package, and works fine, now I put all classes in the default package, which caused me this error :

org.datanucleus.jdo.exceptions.ClassNotPersistenceCapableException: The class "The class "PayPal_Message" is not persistable. This means that it either hasnt been enhanced, or that the enhanced version of the file is not in the CLASSPATH (or is hidden by an unenhanced version), or the Meta-Data/annotations for the class are not found." is not persistable. This means that it either hasnt been enhanced, or that the enhanced version of the file is not in the CLASSPATH (or is hidden by an unenhanced version), or the Meta-Data for the class is not found. NestedThrowables: org.datanucleus.exceptions.ClassNotPersistableException: The class "PayPal_Message" is not persistable. This means that it either hasnt been enhanced, or that the enhanced version of the file is not in the CLASSPATH (or is hidden by an unenhanced version), or the Meta-Data/annotations for the class are not found.

What should I do to fix it ?

解决方案

Explanation: classes in the default package are not visible/importable by classes inside a package.

Try the following examples:

public class Entity {}

(thus without package!) and

package persistence;

public class EntityManager {
    public static void main(String... args) {
        Entity entity = new Entity();
    }
}

Does it work? No? How would you ever import it? That's the problem which happens behind the scenes!

这篇关于Google App Engine ClassNotPersistenceCapableException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆