2011-12-21 127 views
0

我有以下類,我想再接再厲,並正在一個UnexpectedException每當我試圖讓它持久:谷歌的App Engine JDO錯誤

@PersistenceCapable 
public class JdoResidence { 
@PrimaryKey 
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) 
private Key key; 

// Each row should have two columns. [][0] is for last name. [][1] is for first name. 
@Persistent 
private String [] [] names; 

// Address in following format: "12345 Sample St., Indianapolis, IN 12345" 
@Persistent 
private String address; 

// Lot number 
@Persistent 
private int lotNumber; 

// Phone number in following format: 
// "(123) 456-7890" 
@Persistent 
private String phoneNumber; 

public JdoResidence(String[][] names, String address, int lotNumber, String phoneNumber) { 
    this.names = names; 
    this.address = address; 
    this.lotNumber = lotNumber; 
    this.phoneNumber = phoneNumber; 
} 

方法,即拍即JdoResidence持續是:

@Override 
public boolean addResidence(Residence input) { 
    JdoResidence toAdd = new JdoResidence(input.names, input.address, input.lotNumber, input.phoneNumber); 
    PersistenceManager pm = PMF.get().getPersistenceManager(); 
    try { 
     pm.makePersistent(toAdd); 
    } finally { 
     pm.close(); 
    } 
    return true; 

} 

下面是從碼頭日誌:

Dec 21, 2011 10:47:53 PM com.google.appengine.tools.development.ApiProxyLocalImpl log 
SEVERE: javax.servlet.ServletContext log: Exception while dispatching incoming RPC call 
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract boolean com.woodfielddowns.directory.client.ResidenceDataService.addResidence(com.woodfielddowns.directory.shared.Residence)' threw an unexpected exception: java.lang.IllegalArgumentException: names: [Ljava.lang.String; is not a supported property type. 
    at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:385) 
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:588) 
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208) 
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248) 
    at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) 
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166) 
    at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:35) 
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) 
    at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:60) 
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) 
    at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43) 
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) 
    at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122) 
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) 
    at com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:97) 
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) 
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388) 
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) 
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) 
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765) 
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418) 
    at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:78) 
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) 
    at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:362) 
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) 
    at org.mortbay.jetty.Server.handle(Server.java:326) 
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542) 
    at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938) 
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755) 
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218) 
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) 
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409) 
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582) 
Caused by: java.lang.IllegalArgumentException: names: [Ljava.lang.String; is not a supported property type. 
    at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedSingleValue(DataTypeUtils.java:184) 
    at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedValue(DataTypeUtils.java:149) 
    at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedValue(DataTypeUtils.java:123) 
    at com.google.appengine.api.datastore.Entity.setProperty(Entity.java:319) 
    at org.datanucleus.store.appengine.DatastoreFieldManager.storeObjectField(DatastoreFieldManager.java:847) 
    at org.datanucleus.state.AbstractStateManager.providedObjectField(AbstractStateManager.java:1037) 
    at com.woodfielddowns.directory.server.JdoResidence.jdoProvideField(JdoResidence.java) 
    at com.woodfielddowns.directory.server.JdoResidence.jdoProvideFields(JdoResidence.java) 
    at org.datanucleus.state.JDOStateManagerImpl.provideFields(JDOStateManagerImpl.java:2715) 
    at org.datanucleus.store.appengine.DatastorePersistenceHandler.insertPreProcess(DatastorePersistenceHandler.java:357) 
    at org.datanucleus.store.appengine.DatastorePersistenceHandler.insertObjects(DatastorePersistenceHandler.java:267) 
    at org.datanucleus.store.appengine.DatastorePersistenceHandler.insertObject(DatastorePersistenceHandler.java:256) 
    at org.datanucleus.state.JDOStateManagerImpl.internalMakePersistent(JDOStateManagerImpl.java:3185) 
    at org.datanucleus.state.JDOStateManagerImpl.makePersistent(JDOStateManagerImpl.java:3161) 
    at org.datanucleus.ObjectManagerImpl.persistObjectInternal(ObjectManagerImpl.java:1298) 
    at org.datanucleus.ObjectManagerImpl.persistObject(ObjectManagerImpl.java:1175) 
    at org.datanucleus.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:669) 
    at org.datanucleus.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:694) 
    at com.woodfielddowns.directory.server.ResidenceDataServiceImpl.addResidence(ResidenceDataServiceImpl.java:40) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:104) 
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569) 
    ... 34 more 

任何想法,爲什麼一個字符串是不是受支持的屬性類型?

+0

在這裏抱怨的是GWT,而不是JDO。請教GWT關於多維數組的文檔 – DataNucleus

回答

1

多三維Minkowski空間陣列不支持,可能的解決方案是,

  • ,你可以將它保存爲一個ArrayList的(或任何其他收藏,請參閱文檔
  • 或使用,兩個dif名字和姓氏的不同欄目
  • 或將2D數組作爲一個blob。

this threaddocs

+0

結束工作的唯一方法是爲firstNames和lastNames使用兩個單獨的字符串數組。 – ertemplin

1

嘗試更換此

@Persistent 
private String [] [] names; 

與ArrayList的或嵌入對象

0

你也可以把它作爲一個serlialized持久性(@Persistent(serialized = "true")),這將存儲作爲一個blob默認!