嗨我剛剛開始使用Google App Engine,但這個錯誤超出了我的視野。Joda DateTime不支持Google App Engine中的媒體資源類型
試圖在Google App Engine中使用Joda DataTime。我有一個實體,它包含一個dateTime,當它到達em.close()時我會得到這個錯誤。該錯誤顯示「sentTime:org.joda.time.DateTime不是受支持的屬性類型」。
EntityManagerFactory emf = EMF.get();
EntityManager em = null;
try {
em = emf.createEntityManager();
List<Tasks> schedule = patients2.getTasks();
Tasks tasks = new Tasks();
String date = req.getParameter("dateTime")+":00.000-00:00"; DateTime sentTime = new DateTime (date);
tasks.setSentTime(sentTime);
schedule.add(tasks);
patients2.setTasks(schedule);
em.persist(patients2);
}
}
}finally {
if (em != null)
em.close();
}
和堆棧跟蹤
WARNING: /CreateSchedule
java.lang.IllegalArgumentException: sentTime: org.joda.time.DateTime is not a supported property type.
at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedSingleValue(DataTypeUtils.java:235)
at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedValue(DataTypeUtils.java:207)
at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedValue(DataTypeUtils.java:173)
at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedValue(DataTypeUtils.java:148)
at com.google.appengine.api.datastore.PropertyContainer.setProperty(PropertyContainer.java:101)
at com.google.appengine.datanucleus.EntityUtils.setEntityProperty(EntityUtils.java:174)
at com.google.appengine.datanucleus.StoreFieldManager.storeFieldInEntity(StoreFieldManager.java:360)
at com.google.appengine.datanucleus.StoreFieldManager.storeObjectField(StoreFieldManager.java:190)
at org.datanucleus.state.AbstractStateManager.providedObjectField(AbstractStateManager.java:1447)
at healith.Tasks.jdoProvideField(Tasks.java)
at healith.Tasks.jdoProvideFields(Tasks.java)
at org.datanucleus.state.AbstractStateManager.provideFields(AbstractStateManager.java:1515)
at com.google.appengine.datanucleus.DatastorePersistenceHandler.insertObjectsInternal(DatastorePersistenceHandler.java:241)
at com.google.appengine.datanucleus.DatastorePersistenceHandler.insertObject(DatastorePersistenceHandler.java:218)
at org.datanucleus.state.JDOStateManager.internalMakePersistent(JDOStateManager.java:2381)
at org.datanucleus.state.JDOStateManager.flush(JDOStateManager.java:3778)
...
可以通過在pom.xml中只包含datanucleus mvn依賴項來工作嗎?我沒有看到如何將它放在Windows的類路徑上來幫助它在GAE上工作。 – Skychan
此外,如果datanucleus最終只是在java.util.Date和JodaTime的DateTime之間轉換,我猜測時區將會丟失,這是我想要使用JodaTime的原因之一。真正? – Skychan