views:

24

answers:

1

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.

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.

A: 

Quoting the exception "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."

Which one of those possible options is true ?

DataNucleus
I'm a bit puzzled as I've created the class by using the Google plugin for Eclipse, which does the binding automatically and handles the classpath too. So that leads me to the latter two possibilities, i.e. hidden by an unenhanced version, or meta-data/annotations for the class are not found... any suggestions how to determine which's causing the exception.
mobilekid
The Google plugin for Eclipse is nothing to do with DataNucleus so can't comment on what it does, just to say that DataNucleus provides its own Eclipse plugin for auto-enhancing classes and it certainly works. Are the classes enhanced ? look at them with a bytecode decompiler.
DataNucleus