Hi Vitali,

The definitions for DayHourCoordenate is below in my original post and
Appointment is serializable because I make a lot of anothers RPC using
List<Appointment> without problems.


On Wed, Mar 18, 2009 at 6:19 PM, Vitali Lovich <vlov...@gmail.com> wrote:

> The error message tells you exactly the reason:  WeeklyAppointmentData is
> not serializable.  Please refer to the serialization rules of GWT
> (essentially, your classes have to extends IsSerializable, all non-static,
> non-final, non-transient fields must be serializable & you must provide a
> default constructor (any visibility, but it must be there).
>
> Since you don't give the definitions for DayHourCoordenate & Appointment, I
> can't give you the exact reason, but one of those classes is at fault.
>
>
> On Wed, Mar 18, 2009 at 5:13 PM, Alejandro D. Garin <aga...@gmail.com>wrote:
>
>> Hello,
>>
>> I can't serialize a HashMap and I don't understand why. Could you help me
>> please?
>> If I remove the following hashMap the RPC work just fine:
>>
>> private Map<DayHourCoordenate,List<Appointment>> mapData = new
>> HashMap<DayHourCoordenate,List<Appointment>>();
>>
>> *Tomcat error log:*
>>
>> com.google.gwt.user.client.rpc.SerializationException: Type
>> 'com.tasktimer.web.gwt.domain.WeeklyAppointmentData' was not assignable to
>> 'com.google.gwt.user.client.rpc.IsSerializable' and did not have a custom
>> field serializer.  For security purposes, this type will not be serialized.
>>     at
>> com.google.gwt.user.server.rpc.impl.LegacySerializationPolicy.validateSerialize(LegacySerializationPolicy.java:140)
>>     at
>> com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:591)
>>     at
>> com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:129)
>>     at
>> com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter$ValueWriter$8.write(ServerSerializationStreamWriter.java:146)
>>     at
>> com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue(ServerSerializationStreamWriter.java:530)
>>     at com.google.gwt.user.server.rpc.RPC.encodeResponse(RPC.java:573)
>>     at
>> com.google.gwt.user.server.rpc.RPC.encodeResponseForSuccess(RPC.java:441)
>>     at
>> com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:529)
>>     at
>> com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:164)
>>     at
>> com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:86)
>>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
>>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>     at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
>>     at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>>     at
>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
>>     at
>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
>>     at
>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
>>     at
>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>>     at
>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>>     at
>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
>>     at
>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
>>     at
>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
>>     at
>> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
>>     at java.lang.Thread.run(Unknown Source)
>>
>> *The demo clases:*
>>
>> public class SimpleFacadeImpl extends RemoteServiceServlet implements
>> SimpleFacade {
>>
>>   private static final long serialVersionUID = 1164908101444531503L;
>>
>>   public SimpleFacadeImpl() {
>>
>>   }
>>   @Override
>>   public WeeklyAppointmentData getWeeklyData() {
>>     WeeklyAppointmentData data = new WeeklyAppointmentData();
>>     DayHourCoordenate coordenate = new DayHourCoordenate(11,10);
>>     data.add(coordenate, new Appointment());
>>     return data;
>>   }
>> }
>>
>> @RemoteServiceRelativePath("/simpleFacade.do")
>> public interface SimpleFacade extends RemoteService {
>>
>>   public WeeklyAppointmentData getWeeklyData();
>> }
>>
>> public class WeeklyAppointmentData implements Serializable {
>>
>>   private static final long serialVersionUID = 4291039636290439374L;
>>   private Map<DayHourCoordenate,List<Appointment>> mapData = new
>> HashMap<DayHourCoordenate,List<Appointment>>();
>>
>>   public WeeklyAppointmentData() {
>>
>>   }
>>   public void add(DayHourCoordenate coordenate, Appointment appointment) {
>>
>>     List<Appointment> list = mapData.get(coordenate);
>>     if( list == null) {
>>       list = new ArrayList<Appointment>();
>>       mapData.put(coordenate, list);
>>     }
>>     list.add(appointment);
>>   }
>>   public  List<Appointment> get(DayHourCoordenate coordenate) {
>>     return mapData.get(coordenate);
>>   }
>> }
>>
>> public class DayHourCoordenate implements Serializable {
>>
>>   private static final long serialVersionUID = 217370389812685596L;
>>   private int day = 0;
>>   private int hour = 0;
>>
>>   public DayHourCoordenate() {
>>
>>   }
>>   public DayHourCoordenate(int day, int hour) {
>>     this.day = day;
>>     this.hour = hour;
>>   }
>>   public int getDay() {
>>     return day;
>>   }
>>   public void setDay(int day) {
>>     this.day = day;
>>   }
>>   public int getHour() {
>>     return hour;
>>   }
>>   public void setHour(int hour) {
>>     this.hour = hour;
>>   }
>>   @Override
>>   public int hashCode() {
>>     final int prime = 31;
>>     int result = 1;
>>     result = prime * result + day;
>>     result = prime * result + hour;
>>     return result;
>>   }
>>   @Override
>>   public boolean equals(Object obj) {
>>     if (this == obj)
>>       return true;
>>     if (obj == null)
>>       return false;
>>     if (!(obj instanceof DayHourCoordenate))
>>       return false;
>>     DayHourCoordenate other = (DayHourCoordenate) obj;
>>     if (day != other.day)
>>       return false;
>>     if (hour != other.hour)
>>       return false;
>>     return true;
>>   }
>> }
>>
>>
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to