加载 GWT 页面时遇到此错误:
错误com.google.gwt.user.client.rpc.SerializationException: Type 'com.summerbreezemotel.server.DBReservation'
未包含在可由此 SerializationPolicy 序列化的类型集中,或者无法加载其 Class 对象。
我查看了文档,似乎遵循了所有的限制。我还有 3 个其他类做同样的事情,但是这个似乎会引起问题。任何帮助,将不胜感激。
类是failing:DBReservation
package com.summerbreezemotel.server;
import java.util.Date;
import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import com.summerbreezemotel.shared.DataReservation;
import com.summerbreezemotel.shared.SiteConstants;
public class DBReservation extends DataReservation
{
/**
*
*/
private static final long serialVersionUID = 146606067638056872L;
Date dateReserved;
String userEmail;
public DBReservation() {}
public DBReservation(DataReservation in) {
checkIn = in.checkIn;
checkOut = in.checkOut;
form_FirstName = in.form_FirstName;
form_LastName = in.form_LastName;
form_Addr1 = in.form_Addr1;
form_Addr2 = in.form_Addr2;
form_City = in.form_City;
form_State = in.form_State;
form_Zip = in.form_Zip;
form_Country = in.form_Country;
form_Phone = in.form_Phone;
form_Email = in.form_Email;
form_CardType = in.form_CardType;
form_CardMonth = in.form_CardMonth;
form_CardNumber = in.form_CardNumber;
form_CardYear = in.form_CardYear;
form_RoomType = in.form_RoomType;
form_isSmoking = in.form_isSmoking;
form_numRooms = in.form_numRooms;
ratePerNightPerRoom = in.ratePerNightPerRoom;
totalRate = in.totalRate;
}
DataReservation getData()
{
DataReservation out = new DataReservation();
out.checkIn = checkIn;
out.checkOut = checkOut;
out.form_FirstName = form_FirstName;
out.form_LastName = form_LastName;
out.form_Addr1 = form_Addr1;
out.form_Addr2 = form_Addr2;
out.form_City = form_City;
out.form_State = form_State;
out.form_Zip = form_Zip;
out.form_Country = form_Country;
out.form_Phone = form_Phone;
out.form_Email = form_Email;
out.form_CardType = form_CardType;
out.form_CardMonth = form_CardMonth;
out.form_CardNumber = form_CardNumber;
out.form_CardYear = form_CardYear;
out.form_RoomType = form_RoomType;
out.form_isSmoking = form_isSmoking;
out.form_numRooms = form_numRooms;
out.ratePerNightPerRoom = ratePerNightPerRoom;
out.totalRate = totalRate;
return out;
}
// gets item from DB and convertes it to this
void fillReservationFromEntity(Entity item)
{
userEmail = (String) item.getProperty(SiteConstants.USER_PROPERTY);
dateReserved = (Date) item.getProperty(SiteConstants.RESERVE_DATE_PROPERTY);
checkIn = (Date) item.getProperty(SiteConstants.IN_DATE_PROPERTY);
checkOut = (Date) item.getProperty(SiteConstants.OUT_DATE_PROPERTY);
form_FirstName = (String) item.getProperty(SiteConstants.FORM_FIRSTNAME_PROPERTY);
form_LastName = (String) item.getProperty(SiteConstants.FORM_LASTNAME_PROPERTY);
form_Addr1 = (String) item.getProperty(SiteConstants.FORM_ADDR1_PROPERTY);
form_Addr2 = (String) item.getProperty(SiteConstants.FORM_ADDR2_PROPERTY);
form_City = (String) item.getProperty(SiteConstants.FORM_CITY_PROPERTY);
form_State = (String) item.getProperty(SiteConstants.FORM_STATE_PROPERTY);
form_Zip = (String) item.getProperty(SiteConstants.FORM_ZIP_PROPERTY);
form_Country = (String)item.getProperty(SiteConstants.FORM_COUNTRY_PROPERTY);
form_Phone = (String) item.getProperty(SiteConstants.FORM_PHONE_PROPERTY);
form_Email = (String) item.getProperty(SiteConstants.FORM_EMAIL_PROPERTY);
form_CardType = (String) item.getProperty(SiteConstants.FORM_CARDTYPE_PROPERTY);
form_CardMonth = (String) item.getProperty(SiteConstants.FORM_CARDMONTH_PROPERTY);
form_CardNumber = (String) item.getProperty(SiteConstants.FORM_CARDNUMBER_PROPERTY);
form_CardYear = (Long) item.getProperty(SiteConstants.FORM_CARDYEAR_PROPERTY);
form_RoomType = (Long) item.getProperty(SiteConstants.FORM_ROOMTYPE_PROPERTY);
form_isSmoking = (Boolean) item.getProperty(SiteConstants.FORM_ISSMOKING_PROPERTY);
form_numRooms = (Long) item.getProperty(SiteConstants.FORM_NUMROOMS_PROPERTY);
ratePerNightPerRoom = (Double) item.getProperty(SiteConstants.RATEPERNIGHTPERROOM_PROPERTY);
totalRate = (Double) item.getProperty(SiteConstants.TOTALRATE_PROPERTY);
}
void addReservationsToEntity(Entity item)
{
item.setProperty(SiteConstants.USER_PROPERTY, userEmail);
item.setProperty(SiteConstants.RESERVE_DATE_PROPERTY, dateReserved);
item.setProperty(SiteConstants.IN_DATE_PROPERTY, checkIn);
item.setProperty(SiteConstants.OUT_DATE_PROPERTY, checkOut);
item.setProperty(SiteConstants.FORM_FIRSTNAME_PROPERTY,form_FirstName);
item.setProperty(SiteConstants.FORM_LASTNAME_PROPERTY,form_LastName);
item.setProperty(SiteConstants.FORM_ADDR1_PROPERTY,form_Addr1);
item.setProperty(SiteConstants.FORM_ADDR2_PROPERTY,form_Addr2);
item.setProperty(SiteConstants.FORM_CITY_PROPERTY,form_City);
item.setProperty(SiteConstants.FORM_STATE_PROPERTY,form_State);
item.setProperty(SiteConstants.FORM_ZIP_PROPERTY,form_Zip);
item.setProperty(SiteConstants.FORM_COUNTRY_PROPERTY,form_Country);
item.setProperty(SiteConstants.FORM_PHONE_PROPERTY,form_Phone);
item.setProperty(SiteConstants.FORM_EMAIL_PROPERTY,form_Email);
item.setProperty(SiteConstants.FORM_CARDTYPE_PROPERTY,form_CardType);
item.setProperty(SiteConstants.FORM_CARDMONTH_PROPERTY,form_CardMonth);
item.setProperty(SiteConstants.FORM_CARDNUMBER_PROPERTY,form_CardNumber);
item.setProperty(SiteConstants.FORM_CARDYEAR_PROPERTY,form_CardYear);
item.setProperty(SiteConstants.FORM_ROOMTYPE_PROPERTY,form_RoomType);
item.setProperty(SiteConstants.FORM_ISSMOKING_PROPERTY,form_isSmoking);
item.setProperty(SiteConstants.FORM_NUMROOMS_PROPERTY,form_numRooms);
item.setProperty(SiteConstants.RATEPERNIGHTPERROOM_PROPERTY,ratePerNightPerRoom);
item.setProperty(SiteConstants.TOTALRATE_PROPERTY,totalRate);
}
void store()
{
// UserService userService = UserServiceFactory.getUserService();
// User user = userService.getCurrentUser();
// if(user.getEmail() != null)
// userEmail = user.getEmail();
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
String SummerBreezeDateStoreName = new String(SiteConstants.KEY_NAME);
Key SummerBreezeDateStoreKey = KeyFactory.createKey(SiteConstants.KEY_KEY, SummerBreezeDateStoreName);
Entity reservationsEntry = new Entity(SiteConstants.DB_RESERVATIONS, SummerBreezeDateStoreKey);
addReservationsToEntity(reservationsEntry);
datastore.put(reservationsEntry);
// use this if writes get to high
// item.setProperty("testBlob",new Blob(toByte(roomResevationRequest)));
datastore.put(reservationsEntry);
}
}
我的数据预订
package com.summerbreezemotel.shared;
import java.io.Serializable;
import java.util.Date;
public class DataReservation implements Serializable
{
private static final long serialVersionUID = -7598404617383692994L;
public String form_FirstName;
public String form_LastName;
public String form_Addr1;
public String form_Addr2;
public String form_City;
public String form_State;
public String form_Zip;
public String form_Country;
public String form_Phone;
public String form_Email;
public String form_CardType;
public String form_CardMonth;
public String form_CardNumber;
public long form_CardYear;
public long form_RoomType;
public boolean form_isSmoking;
public Date checkIn;
public Date checkOut;
public long form_numRooms;
public double ratePerNightPerRoom;
public double totalRate;
public DataReservation()
{
}
}