Gwt serialization synchronization mode not synchronized

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" /> <!-- JAXB API sources needed for GWT compilation of JAXB annotated classes --> <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" /> <!-- JAXB API sources needed for GWT compilation of JAXB annotated classes --> <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?

+7
source share
2 answers

I have the same problem. The only solution I see is to make sure you have the same .gwt.rpc files on both sides.

This means that every time you start or restart Dev Mode, you must replace the old .gwt.rpc files deployed on your web server with new ones.

Or you specify the Dev Mode output directory in the context of the web server. Make sure the web server is turned on automatically. Therefore, every time files are changed in Dev mode, the web server automatically reloads the files.

+3
source

Based on what I see in com.google.gwt.user.rebind.rpc.ProxyCreator , GWT generates the policy file names .gwt.rpc of the serialization policy by its content (md5).

So, for some reason, the serialization policy in Super Dev mode is different from the one that was created during normal build.

The following approach fixed the problem for me:

  • Open the serialization policy file .gwt.rpc generated for the regular build
  • Open the serialization policy file .gwt.rpc generated for Super Dev mode. You can find where it is by looking at the working directory printed when Super Dev mode starts. For example. in my case it was: "workDir: C: \ Users \ your_user \ AppData \ Local \ Temp \ gwt-codeserver-5658052675265790575.tmp"
  • Compare 2 files - this may give you a pretty good hint as to where the problem might be. In my case, 2 unnecessary types were added to the serialization policy, and I could just completely remove them from the project.
  • After fixing the inconsistencies, the name of the .gwt.rpc file should be identical again, and the problem will be fixed :)
0
source

All Articles