I have a perfectly working GWT application. Now I am trying to use gwt-syncproxy
to create an Android client which can simply reuse the server side code.
So far everything was working perfectly. The only problem that I can find is when I start RPC to a method expecting an enum as a parameter.
The enum looks something like this:
import java.io.Serializable;
import com.google.gwt.user.client.rpc.IsSerializable;
public enum ReferenceTable implements IsSerializable, Serializable
{
basetable, othertable;
ReferenceTable(){}
}
The error message I'm getting is:
com.google.gwt.user.client.rcp.IncompatibleRemoteServiceException: Invalid type signature for package.ReferenceTable
which suggests that it's a problem related to serialization.
I tried using different combinations of IsSerializable
and Serializable
and always cleaned the project before deploying. Both the GWT app and the Android app use the same code for the data types used for communication.
Does anyone have an idea how to solve this? If nothing else works, I could refrain from using enums, but I would prefer using them. Especially, since everything is working for the GWT server-client communication itself.
BTW: The error on the server side is:
Caused by: com.google.gwt.user.client.rpc.SerializationException: Invalid type signature for some.package.ReferenceTable
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.validateTypeVersions(ServerSerializationStreamReader.java:1116)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.deserialize(ServerSerializationStreamReader.java:610)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.readObject(ServerSerializationStreamReader.java:567)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader$ValueReader$8.readValue(ServerSerializationStreamReader.java:140)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.deserializeValue(ServerSerializationStreamReader.java:425)
at com.google.gwt.user.server.rpc.RPC.decodeRequest(RPC.java:312)
... 24 more
EDIT:
I created both a sample GWT app and a sample Android app, so people can actually try the code:
To deploy the app, just modify the build.properties
file and then run build.xml
as an ant script. In the MainActivity
of the Android app, modify the URL to point to the GWT app.
I am unable to verify your issue as described (using your provided src, it works in my dev environment using a JB emulator), though I have seen your specified error during development of the Android library. I have found that many of the "Serialization" issues in GWT are usually something small such as unserializable member types, missing interfaces, default constructors, etc. Since it seems you have already addressed those possibilities, please verify the following:
Version of GWT being used in web-app on your machine. Android OS Version being tested on (emulator or Device) and which device if appropriate.
Though I dont expect it to be an issue, the Android library is compiled with GWT 2.5.0 src, so it's possible (an as yet untested theory) that if the server is running GWT other than 2.5.0, the RPC serialization is failing due to that.
This would also explain why the desktop client works and the android library does not. The desktop client syncproxy library is compiled against GWT, not with GWT, so you link your version of GWT at compile time. The Android library was compiled directly with GWT src code for 2.5.0 with a few custom overrides in order to reduce the size of the library to be usable and manageable in the Dalvik environment.
That said, if its possible for your project, try using GWT 2.5.0, clean/recompile and give that a shot. If not, it's on my todo list to get the library up to 2.5.1, but I haven't had time as yet.
Disclaimer: I created the Android library in question as a contributor to the gwt-syncproxy project. I can't claim to understand all the ins and outs of GWT or the syncproxy internals, but at least enough to get the working model of the library functional. I'm open to suggestions on improvement of the library or any ideas of where in the internals we should look to resolve this if any gwt-guru's are out there...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With