ClassNotPersistenceCapableException [英] ClassNotPersistenceCapableException

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

问题描述

在尝试保留以下JDO类时,我收到ClassNotPersistenceCapableException.

I'm getting ClassNotPersistenceCapableException when trying to persist the following JDO class.

package com.xxx.cms.model;

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

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

@PersistenceCapable
public class Transaction {

    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;

    @Persistent
    private String type;

    @Persistent
    private Text details;

    @Persistent
    private Company client;

    @Persistent
    private Carrier carrier;

    @Persistent
    private Company sender;

    @Persistent
    private Company recipient;

    @Persistent
    private Customs customs;

    public Transaction(String type, Text details, Company client, Carrier carrier, Company sender, Company recipient, Customs customs){
        this.setType(type);
        this.setDetails(details);
        this.setClient(client);
        this.setCarrier(carrier);
        this.setSender(sender);
        this.setRecipient(recipient);
        this.setCustoms(customs);
    }
....
}

然后,当我运行以下命令时:

Then when I run the following:

PersistenceManager pm = PMF.get().getPersistenceManager();
        try {
            pm.makePersistent(carrier);
            pm.makePersistent(sender);
            pm.makePersistent(recipient);
            pm.makePersistent(client);
            pm.makePersistent(cargo);
            pm.makePersistent(finance);
            pm.makePersistent(customs);

            Transaction transaction = new Transaction(transactionType, transactionDetails, client, carrier, sender, recipient, customs);        

            pm.makePersistent(transaction);
        } finally {


pm.close();
    }

我在应用程序日志中遇到以下异常:

I get the following exception in the app logs:

org.datanucleus.jdo.exceptions.ClassNotPersistenceCapableException: The class "The class "com.xxx.cms.model.Transaction" 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.

任何想法为何GAE都会抛出此异常?从数据查看器中可以看到,其他类的数据已成功持久保存.

Any ideas why GAE is throwing this exception? The data from the other classes is persisted successfully as I can see it from the data viewer.

推荐答案

这是因为尝试DataNucleus尝试注册相同的插件.如果通过停止本地服务器看到控制台,它将显示为-

This is becuse trying DataNucleus is trying to register an identical plugin. If you see console by stopping you local server, it will show as -

DataNucleus Enhancer(版本1.1.4):类的增强遇到问题:意外的异常,请参阅日志的[C:\ Users \ AppData \ Local \ Temp \ enhance9016551549771995762.log]进一步的信息.

DataNucleus Enhancer (version 1.1.4) : Enhancement of classes Encountered a problem: Unexpected exception Please see the logs [C:\Users\AppData\Local\Temp\enhance9016551549771995762.log] for further information.

然后请检查日志文件..

Then please check the log file ..

该错误突出显示为-

    Caused by: org.datanucleus.exceptions.NucleusException: Plugin (Bundle) "org.datanucleus" is already registered. Ensure you dont have multiple JAR versions of the same plugin in the classpath. 
The URL "file:/C:/VB/Softwares/eclipse-jee-mars-1-win32-x86_64/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.9.30/appengine-java-sdk-1.9.30/lib/opt/tools/datanucleus/v2/datanucleus-core-3.1.3.jar" is already registered, and you are trying to register an identical plugin located at URL "file:/C:/VB/Softwares/eclipse-jee-mars-1-win32-x86_64/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.9.30/appengine-java-sdk-1.9.30/lib/opt/user/datanucleus/v1/datanucleus-core-1.1.5.jar."

因此,同一jar数据核具有两个版本.

Thus same jar datanucleus-core having two version.

现在转到错误显示的路径,然后删除完整的v1文件夹,因为您拥有最新的v2文件夹使用相同的最新jar并重新启动服务器,这将起作用....

Now go to the path shown in error and Just delete the complete v1 folder as you have the latst v2 folder with same latest jars and re-start your server, this will work....

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

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