我正在尝试在GAE中建立一对多的关系,当我添加到列表中时,我收到以下错误:
[java] java.lang.NullPointerException
[java] at com.google.appengine.datanucleus.scostore.FKListStore.getIndexPropertyName(FKListStore.java:965)
[java] at com.google.appengine.datanucleus.scostore.FKListStore.getFilterPredicates(FKListStore.java:940)
[java] at com.google.appengine.datanucleus.scostore.FKListStore.listIterator(FKListStore.java:383)
[java] at com.google.appengine.datanucleus.scostore.FKListStore.listIterator(FKListStore.java:349)
[java] at com.google.appengine.datanucleus.scostore.FKListStore.iterator(FKListStore.java:342)
[java] at org.datanucleus.store.types.sco.backed.List.loadFromStore(List.java:304)
[java] at org.datanucleus.store.types.sco.backed.List.add(List.java:685)
[java] at Utils.GardenUtils.PostMessage(GardenUtils.java:187)
[java] at Servlets.GardenServlets.PostGardenMessageServlet.processRequest(PostGardenMessageServlet.java:28)
[java] at Servlets.GardenServlets.PostGardenMessageServlet.doPost(PostGardenMessageServlet.java:70)
[java] at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
[java] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
[java] at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
[java] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
[java] at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
[java] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[java] at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:127)
[java] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[java] at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
[java] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[java] at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
[java] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[java] at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
[java] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[java] at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
[java] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[java] at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:366)
[java] at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:349)
[java] at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)
[java] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[java] at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
[java] at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
[java] at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
[java] at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
[java] at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
[java] at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:98)
[java] at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
[java] at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:491)
[java] at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
[java] at org.mortbay.jetty.Server.handle(Server.java:326)
[java] at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
[java] at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
[java] at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
[java] at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
[java] at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
[java] at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
[java] at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
这就是我添加新列表成员的方式:
public static void PostMessage(String userID, String gardenKey, String content) {
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
User user = pm.getObjectById(User.class, userID);
GardenMessage message = new GardenMessage();
message.setFirstName(user.getFirstName());
message.setLastName(user.getLastName());
message.setUserID(userID);
message.setContent(content);
message.setGardenKey(gardenKey);
message.setPostDate(new Date());
Garden garden = pm.getObjectById(Garden.class, gardenKey);
garden.getMessages().add(message);
} finally {
pm.close();
}
}
在花园课上我有这个:
@Persistent
private List<GardenMessage> messages;
请告诉我我的代码有什么问题。
答案 0 :(得分:0)
AFAIK的谷歌插件在最后一个版本(2.1.2)之后有几次更新,他们并没有打扰它。代码位于http://code.google.com/p/datanucleus-appengine/source/browse/#svn%2Ftrunk 你有一个NPE的线路肯定不同于粗略的一瞥,所以建议你试试他们当前的SVN。你应该能够简单地做一个结账,然后&#34; mvn clean install&#34;获得版本3.0.0-SNAPSHOT(使用DataNucleus 3.2 IIRC)。
简单搜索还发现了这篇文章javax.jdo.JDOException: Unexpected error during precommit