SerializationPolicy error when performing RPC from within GWT application

后端 未结 10 2006
醉梦人生
醉梦人生 2020-12-14 01:59

I\'m getting the following exception:

com.google.gwt.user.client.rpc.SerializationException: Type \'java.lang.Long\' was not included in the set of ty

相关标签:
10条回答
  • 2020-12-14 02:58

    FYI I've raised this as a GWT bug: http://code.google.com/p/google-web-toolkit/issues/detail?id=5811

    We'll see what they say.

    0 讨论(0)
  • 2020-12-14 03:01

    Try deleting the *.gwt.rpc files in your war/app directory, clean and rebuild.

    One thing to note: you should avoid long or Long if possible because they are
    emulated on GWT (because there is no native Javascript long) and very
    slow. Use int instead where ever you can.

    0 讨论(0)
  • 2020-12-14 03:01

    Inspired by http://groups.google.com/group/google-web-toolkit/browse_thread/thread/7dd5123d359ddfa8

    Using eclipse and maven and gwt 2.1.1

    Compile and deploy gwt war.

    Try using OOPHM launched from Eclipse.

    This would fail for me.

    This will generate in server logs:

    ERROR: The serialization policy file 'blah.gwt.rpc' was not found; did you forget to include it in this deployment?

    WARNING: Failed to get the SerializationPolicy '94DEC228B2828D3A5897FEE3D6845A40' for module 'http://blah:8080/BlahUI/BlahUI/'; a legacy, 1.3.3 compatible, serialization policy will be used. You may experience SerializationExceptions as a result.

    And then

    Exception while dispatching incoming RPC call com.google.gwt.user.client.rpc.SerializationException: Type '[LpathToClass;' 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 = [LpathToClass;@9d524af at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:614)

    Now that extra gwt.rpc files have been generated (either by eclipse/maven plugin who knows?)

    Recompile (even a clean compile will work because the gwt.rpc files are not in the target folder, my OOPHM gwt.rpc files are at same folder as entrypoint html) and redeploy. This new war file will contain the generated gwt.rpc files.

    Relaunch OOPHM from Eclipse.

    Works for me.

    0 讨论(0)
  • 2020-12-14 03:02

    FWIW, I was having this problem but my 'Object' type was hidden behind generified classes. The error message itself was wrong.

    So if one of your rpc methods involves a class:

    class Xxx<T> implements IsSerializable {...
    

    It needs to change to:

    class Xxx<T extends IsSerializable> implements IsSerializable {...
    
    0 讨论(0)
提交回复
热议问题