When I run my GWT application (gwt 2.0.4) in host mode by invoking RPC methods running on a remote Tomcat, I get a GWT serialization exception:
INFO: GwtRpcEventSrvc: ERROR: The serialization policy file '/84EC7BA65AF8175BAA99B47877FDE163.gwt.rpc' was not found; did you forget to include it in this deployment? SEVERE: GwtRpcEventSrvc: WARNING: Failed to get the SerializationPolicy '84EC7BA65AF8175BAA99B47877FDE163' for module 'http://host:19980/MYAPP/'; a legacy, 1.3.3 compatible, serialization policy will be used. Youmay experience SerializationExceptions as a result. SEVERE: Exception while dispatching incoming RPC call Throwable occurred: com.google.gwt.user.client.rpc.SerializationException: java.lang.reflect.InvocationTargetException .at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeWithCustomSerializer(ServerSerializationStreamWriter.java:760) .at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeImpl(ServerSerializationStreamWriter.java:723) .at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:612) .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:152) ... Caused by: com.google.gwt.user.client.rpc.SerializationException: Type 'com.mypackage.data.MyData' 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.: instance = com.mypackage.data.MyData@1b061b06 .at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:610) .at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:129) .at com.google.gwt.user.client.rpc.core.java.util.Collection_CustomFieldSerializerBase.serialize(Collection_CustomFieldSerializerBase.java:43) .at com.google.gwt.user.client.rpc.core.java.util.LinkedList_CustomFieldSerializer.serialize(LinkedList_CustomFieldSerializer.java:36) .... 33 more
The host mode generates serialization policy files (* .gwt.rpc) with different md5 that were created during GWT compilation - they are deployed to my server. GWT lacks a serialization policy file that wants to support client mode.
When working in non-hosting mode, everything is fine.
I tried to run the host mode through Ant or the Eclipse debug configuration with the same results. The GWT compilation class classpath and host class path (including) are the same.
Compiling a GWT Ant script:
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler"> <classpath> <pathelement location="${basedir}/src" /> <pathelement location="${dir.build.root}/ProjectA/src" /> <pathelement location="${dir.build.root}/ProjectB/src" /> <pathelement location="${dir.build.root}/ProjectC/src" /> <pathelement location="${dir.build.root}/ProjectD/src" /> <pathelement location="${dir.build.root}/ProjectE/src" /> <pathelement location="${dir.root}/ProjectD/src" /> <pathelement location="${dir.root}/THIRDPARTY/build/athirdparty.jar" /> <pathelement location="${dir.commons.gwtcompiler}/gwt-user.jar" /> <pathelement location="${dir.commons.gwtcompiler}/gwt-dev.jar" /> <pathelement location="../ExternalLibs/libs/gwt-log-3.0.0.jar" /> <pathelement location="../ExternalLibs/nonshipjars/jaxb-api-src.zip" /> </classpath> <jvmarg value="-Xmx1g" /> <jvmarg value="-Dgwt.nowarn.metadata" /> <arg line="-localWorkers 2 -style OBF" /> <arg line="-war ${basedir}/www" /> <arg line="-extra ${basedir}/build" /> <arg value="com.myapp.Main" /> </java>
Running in host mode - Ant script:
<target name="hosted" description="Run hosted mode"> <java failonerror="true" fork="true" classname="com.google.gwt.dev.HostedMode"> <classpath> <pathelement location="${basedir}/src" /> <pathelement location="${dir.build.root}/ProjectA/src" /> <pathelement location="${dir.build.root}/ProjectB/src" /> <pathelement location="${dir.build.root}/ProjectC/src" /> <pathelement location="${dir.build.root}/ProjectD/src" /> <pathelement location="${dir.build.root}/ProjectE/src" /> <pathelement location="${dir.root}/ProjectD/src" /> <pathelement location="${dir.root}/THIRDPARTY/build/athirdparty.jar" /> <pathelement location="${dir.commons.gwtcompiler}/gwt-user.jar" /> <pathelement location="${dir.commons.gwtcompiler}/gwt-dev.jar" /> <pathelement location="../ExternalLibs/libs/gwt-log-3.0.0.jar" /> <pathelement location="../ExternalLibs/nonshipjars/jaxb-api-src.zip" /> </classpath> <jvmarg value="-Xmx1g" /> <jvmarg value="-Dgwt.nowarn.metadata" /> <arg line="com.myapp.Main" /> <arg line="-startupUrl" /> <arg line=" http://host:19980/MYAPP/Main.html" /> <arg line="-whitelist" /> <arg line="^http[:][/][/]host[:]19980" /> <arg line="-whitelist" /> <arg line=" ^http[:][/][/]localhost" /> <arg line="-whitelist" /> <arg line="^http[:][/][/]127.0.0.1" /> <arg line="-port" /> <arg line="8080" /> <arg line="-noserver" /> <arg line="-logLevel" /> <arg line="DEBUG" /> </java> </target>
RPC Method Signature:
public List<MyData> getSmpeWorkDddefZonesData(String processId);
MyData definition (declared in ProjectE, which is not a GWT project - data layer):
package com.mypackage.data; import java.io.Serializable; public interface MyData extends Serializable {...
MyData is bundled in a module inherited from another GWT module: com.mypackage.Data.gwt.xml :
<module> <source path="data" /> </module>
Main module com.myapp.Main.gwt.xml :
... <inherits name="com.mypackage.Data" /> ...
How to make hosting generate the same serialization policy files?