Here's a similar thread with possible workarounds: http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/a3081e050d5b719a#
On Apr 2, 4:32 pm, snorbi <sandor.norb...@erinors.com> wrote: > Hello, > > We have problems serializing generic Maps in gwt-1.6.2 (both in web > and hosted mode). It seems that type parameters of generic remote > service method parameters are not scanned properly when searching for > potential serializable types. > > To reproduce the problem, please see the application snippet below. It > is a minimal GWT application which calls a remote service from its > entry method. > Running the application results in the following exception: > > [ERROR] failure > com.google.gwt.user.client.rpc.SerializationException: > gwtsandbox.client.Parameter > at > gwtsandbox.client.Service_TypeSerializer.raiseSerializationException > (Service_TypeSerializer.java:69) > at gwtsandbox.client.Service_TypeSerializer.serialize(Native Method) > at > com.google.gwt.user.client.rpc.impl.ClientSerializationStreamWriter.serialize > (ClientSerializationStreamWriter.java:216) > at > com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject > (AbstractSerializationStreamWriter.java:129) > at > com.google.gwt.user.client.rpc.core.java.util.Map_CustomFieldSerializerBase.serialize > (Map_CustomFieldSerializerBase.java:50) > at > com.google.gwt.user.client.rpc.core.java.util.HashMap_CustomFieldSerializer.serialize > (HashMap_CustomFieldSerializer.java:36) > at gwtsandbox.client.Service_TypeSerializer.serialize(Native Method) > at > com.google.gwt.user.client.rpc.impl.ClientSerializationStreamWriter.serialize > (ClientSerializationStreamWriter.java:216) > at > com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject > (AbstractSerializationStreamWriter.java:129) > at gwtsandbox.client.Service_Proxy.serviceMethod(Service_Proxy.java: > 31) > at gwtsandbox.client.Application.onModuleLoad(Application.java:20) > > Uncommenting the lines marked with "// FIX", it works as expected. > > I think it is a bug, what do you think? > > Thanks for your help! > Regards: > Norbi > > Application.gwt.xml > ------------------- > <module> > <inherits name='com.google.gwt.user.User' /> > <entry-point class='gwtsandbox.client.Application' /> > <source path="client" /> > </module> > > Application.java > ---------------- > package gwtsandbox.client; > > import java.util.HashMap; > import java.util.Map; > > import com.google.gwt.core.client.EntryPoint; > import com.google.gwt.core.client.GWT; > import com.google.gwt.user.client.Window; > import com.google.gwt.user.client.rpc.AsyncCallback; > import com.google.gwt.user.client.rpc.ServiceDefTarget; > > public class Application implements EntryPoint { > public void onModuleLoad() { > Map<String, Object> map = new HashMap<String, Object>(); > map.put("key", new Parameter(5)); > > ServiceAsync serviceProxy = GWT.create(Service.class); > ((ServiceDefTarget) serviceProxy).setServiceEntryPoint > (GWT.getHostPageBaseURL() + "gwt/rpc/" > + Service.class.getName()); > serviceProxy.serviceMethod(map, new AsyncCallback<Void>() { > @Override > public void onFailure(Throwable caught) { > Window.alert(caught.toString()); > System.out.println(caught); > } > > @Override > public void onSuccess(Void result) { > Window.alert("success"); > } > }); > } > > } > > Parameter.java > -------------- > package gwtsandbox.client; > > import java.io.Serializable; > > import com.google.gwt.user.client.rpc.IsSerializable; > > public class Parameter implements Serializable, IsSerializable { > private static final long serialVersionUID = 1L; > > private int value; > > public Parameter() { > } > > public Parameter(int value) { > setValue(value); > } > > public int getValue() { > return value; > } > > public void setValue(int value) { > this.value = value; > } > > } > > Service.java > ------------ > package gwtsandbox.client; > > import java.util.Map; > > import com.google.gwt.user.client.rpc.RemoteService; > > public interface Service extends RemoteService { > void serviceMethod(Map<String, Object> map); > > // FIX void serviceMethod(Parameter parameter); > > } > > ServiceAsync.java > ----------------- > package gwtsandbox.client; > > import java.util.Map; > > import com.google.gwt.user.client.rpc.AsyncCallback; > > public interface ServiceAsync { > void serviceMethod(Map<String, Object> map, AsyncCallback<Void> > callback); > > // FIX void serviceMethod(Parameter parameter, AsyncCallback<Void> > callback); > > } > > ServiceServlet.java > ------------------- > package gwtsandbox.server; > > import java.util.Map; > > import gwtsandbox.client.Parameter; > import gwtsandbox.client.Service; > > import com.google.gwt.user.server.rpc.RemoteServiceServlet; > > public class ServiceServlet extends RemoteServiceServlet implements > Service { > private static final long serialVersionUID = 1L; > > @Override > public void serviceMethod(Map<String, Object> map) { > System.out.println("Service called: " + map); > } > > // FIX @Override > public void serviceMethod(Parameter parameter) { > System.out.println("Service called: " + parameter); > } > > } > > web.xml > ------- > <?xml version="1.0" encoding="UTF-8"?> > <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http:// > java.sun.com/xml/ns/javaee/web-app_2_5.xsd" > > xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" > id="WebApp_ID" version="2.5"> > <display-name>gwt-sandbox</display-name> > <welcome-file-list> > <welcome-file>index.html</welcome-file> > </welcome-file-list> > <servlet> > <servlet-name>Service</servlet-name> > > <servlet-class>gwtsandbox.server.ServiceServlet</servlet-class> > <load-on-startup>1</load-on-startup> > </servlet> > <servlet-mapping> > <servlet-name>Service</servlet-name> > <url-pattern>/gwt/rpc/gwtsandbox.client.Service</url-pattern> > </servlet-mapping> > </web-app> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---