I think I see it.  List is not generally serializable.  The recommendation I
recall reading somewhere is to try to use super-classes as infrequently as
possible because it makes the compiler's job more difficult - also, in this
particular case, the GWT compiler is unable to determine the type to
serialize to.

Try:

private Map<DayHourCoordenate,ArrayList<Appointment>> mapData = new
HashMap<DayHourCoordenate,ArrayList<Appointment>>();

or even more preferable, change mapData to a HashMap as well.


On Wed, Mar 18, 2009 at 6:05 PM, Vitali Lovich <[email protected]> wrote:

> That depends on the version of GWT he's using.  As of 1.5 (or 1.4 - can't
> recall the exact version), Serializable is a synonym for IsSerializable
>
>
> On Wed, Mar 18, 2009 at 5:15 PM, George Holler <[email protected]>wrote:
>
>>
>>
>> The class WeeklyAppointmentData does not appear to implement
>> IsSerializable. That's in the first line of the error stack trace.
>>
>> G
>>
>> --- On Wed, 3/18/09, Alejandro D. Garin <[email protected]> wrote:
>>
>> > From: Alejandro D. Garin <[email protected]>
>> > Subject: SerializationException when serialize a HashMap over RPC
>> > To: [email protected]
>> > Date: Wednesday, March 18, 2009, 5:13 PM
>> > 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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to