私が欠けているものがあります:
Serializable Typesでは、何がシリアライズされるかが明示的に示されています。
型はシリアライズ可能な型の配列です (他のシリアライズ可能な配列を含みます)。
しかし、私はシリアライズすることはできませんnew String[]{"s"}
public void onModuleLoad()
{
HashMap<String, String[]> p = new HashMap<String, String[]>();
p.put("xxx", new String[]{"s"});
ArrayList params = new ArrayList();
params.add(p);
greetingService.greetServer(params, new AsyncCallback<String>()
{
@Override
public void onSuccess(String result)
{
// TODO Auto-generated method stub
}
@Override
public void onFailure(Throwable caught)
{
caught.printStackTrace();
}
});
}
一方、これをシリアル化できます:
ArrayList list = new ArrayList();
list.add("s");
これが私が得る例外です:
com.google.gwt.user.client.rpc.SerializationException
at com.google.gwt.user.client.rpc.impl.SerializerBase.getTypeHandler(SerializerBase.java:153)
at com.google.gwt.user.client.rpc.impl.SerializerBase.serialize(SerializerBase.java:125)
at com.google.gwt.user.client.rpc.impl.ClientSerializationStreamWriter.serialize(ClientSerializationStreamWriter.java:183)
at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:126)
at com.google.gwt.user.client.rpc.core.java.util.Map_CustomFieldSerializerBase.serialize(Map_CustomFieldSerializerBase.java:53)
at com.google.gwt.user.client.rpc.core.java.util.HashMap_CustomFieldSerializer.serialize(HashMap_CustomFieldSerializer.java:39)
at com.google.gwt.user.client.rpc.core.java.util.HashMap_FieldSerializer.serial(HashMap_FieldSerializer.java:23)
at com.google.gwt.user.client.rpc.impl.SerializerBase.serialize(SerializerBase.java:126)
at com.google.gwt.user.client.rpc.impl.ClientSerializationStreamWriter.serialize(ClientSerializationStreamWriter.java:183)
at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:126)
at com.google.gwt.user.client.rpc.core.java.util.Collection_CustomFieldSerializerBase.serialize(Collection_CustomFieldSerializerBase.java:44)
at com.google.gwt.user.client.rpc.core.java.util.ArrayList_CustomFieldSerializer.serialize(ArrayList_CustomFieldSerializer.java:39)
at com.google.gwt.user.client.rpc.core.java.util.ArrayList_FieldSerializer.serial(ArrayList_FieldSerializer.java:23)
at com.google.gwt.user.client.rpc.impl.SerializerBase.serialize(SerializerBase.java:126)
at com.google.gwt.user.client.rpc.impl.ClientSerializationStreamWriter.serialize(ClientSerializationStreamWriter.java:183)
at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:126)
at com.example.client.GreetingService_Proxy.greetServer(GreetingService_Proxy.java:31)
at com.example.client.AnotherTest.onModuleLoad(AnotherTest.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:396)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Thread.java:662)
サービスは次のとおりです。
@RemoteServiceRelativePath("greet")
public interface GreetingService extends RemoteService
{
String greetServer(ArrayList name) throws IllegalArgumentException;
}