Java Google应用程序引擎类NotPersistenceCapableException
我有以下课程:Java Google应用程序引擎类NotPersistenceCapableException,java,google-app-engine,persistence,Java,Google App Engine,Persistence,我有以下课程: 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.
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; }
}
它以前在一个包中,工作正常,现在我将所有类都放在默认包中,这导致我出现以下错误:
org.datanucleus.jdo.exceptions.ClassNotPersistenceCapableException:类PayPal_消息的类是不可持久的。这意味着它要么没有被增强,要么文件的增强版本不在类路径中,要么被未增强版本隐藏,或者找不到类的元数据/注释。是不持久的。这意味着它或者没有被增强,或者文件的增强版本不在类路径中,或者被未增强版本隐藏,或者找不到类的元数据。
嵌套的工作流表:
org.datanucleus.exceptions.ClassNotPersistableException:类PayPal_消息不可持久化。这意味着它要么没有被增强,要么文件的增强版本不在类路径中,要么被未增强版本隐藏,或者找不到类的元数据/注释
我该怎么做才能修复它呢?我有时会因为无法辨别的原因而遇到这些异常
在persistent类的某个地方添加一个空间并进行重建,这在过去已经为我解决了这个问题。不知道为什么会发生这种情况,也不知道为什么重建会修复它,但至少值得一试。我最终将它们放回包中,现在它工作正常。说明:默认包中的类对于包中的类不可见/不可导入 请尝试以下示例:
public class Entity {}
因此没有包装!及
package persistence;
public class EntityManager {
public static void main(String... args) {
Entity entity = new Entity();
}
}
它有用吗?不你将如何导入它?这就是发生在幕后的问题 为什么要把它放在默认包中?出于某种原因使用包是一种最佳做法,但我将该项目中的所有Cals都放在默认包中,为什么它不能工作?因为在本例中使用Datanucleus的持久性API没有使用默认包。这不是字面上的上述代码,但这是发生在幕后。无法从上的其他包访问默认包中的类。