-1

I have the following code deployed to an app engine server (the only place where I can test JDO, unfortunately I cannot test JDO locally because I don't have a local BigTable implementation).

final class PMF {

  private static final PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory("transactions-optional");

  private PMF() { }

  public static PersistenceManagerFactory get() { return pmf; }

}

@PersistenceCapable
class Data {
  // ...
  @Persistent
  private static List<Store> stores = new ArrayList<Store>();

  static List<Store> getStores() {

    return stores;

  }

}

...

Data.getStores().add(store);
writer.write("this line received OK by client.");
PMF.get().getPersistenceManager().makePersistent(Data.getStores()); 
writer.write("this line never received by client.");

As shown the first line of output from the server is received on the client and the second one is not which means makePersistent() is failing.

Anyone have any idea why this is happening?

Marvin Pinto
  • 30,138
  • 7
  • 37
  • 54
johngoche9999
  • 1,641
  • 2
  • 14
  • 21
  • Following Rick Mangi reply you can copy what is done in http://code.google.com/p/datanucleus-appengine/source/browse/ under the tests are. That's how the JDO plugin is developed in the first place. – DataNucleus Jan 27 '12 at 08:16

2 Answers2

1

Perhaps the simple fact that no standard persistence API for Java provides persistence of static fields.

DataNucleus
  • 15,497
  • 3
  • 32
  • 37
  • Thanks, I was suspecting that might be the case but wasn't sure. I think the solution is to make the List nonstatic and put in a static member function that uses JDOQL to retrieve the single instance of the Data class used throughout the code. Any comments on this approach? Thanks, John Goche – johngoche9999 Jan 26 '12 at 20:35
  • In fact I decided to debug with { writer.write(e.toString(); } and here was the error message: org.datanucleus.jdo.exceptions.ClassNotPersistenceCapableException: The class "The class "java.util.ArrayList" 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 – johngoche9999 Jan 26 '12 at 20:39
  • And also add to that the fact that you are passing a List into makePersistent which is simply wrong. You pass a persistable object into makePersistent. – DataNucleus Feb 04 '12 at 09:03
1

You can mimic BigTable on your local machine by running your code locally using ant or the eclipse appengine plugin. The eclipse plugin also runs datanucleus in the background and will catch errors like this for you without having to upload to appengine whenever you make a change.

Rick Mangi
  • 3,761
  • 1
  • 14
  • 17
  • Thanks, I am now running the code locally with the same results as on the server, but I'm having the following problem which I don't know how to deal with: http://stackoverflow.com/questions/9053448/jdo-on-gae-pm-makepersistent-throws-nullpointerexception – johngoche9999 Jan 29 '12 at 17:21