How do I add a type to GWT's Serialization Policy whitelist?

后端 未结 9 636
离开以前
离开以前 2020-11-30 01:30

GWT\'s serializer has limited java.io.Serializable support, but for security reasons there is a whitelist of types it supports. The documentation I\'ve found,

9条回答
  •  天涯浪人
    2020-11-30 01:58

    I had this problem but ended up tracing the problem back to a line of code in my Serializable object:

    Logger.getLogger(this.getClass().getCanonicalName()).log(Level.INFO, "Foo");
    

    There were no other complaints before the exception gets caught in:

     @Override
      protected void serialize(Object instance, String typeSignature)
          throws SerializationException {
        assert (instance != null);
    
        Class clazz = getClassForSerialization(instance);
    
        try {
          serializationPolicy.validateSerialize(clazz);
        } catch (SerializationException e) {
          throw new SerializationException(e.getMessage() + ": instance = " + instance);
        }
        serializeImpl(instance, clazz);
      }
    

    And the business end of the stack trace is:

    com.google.gwt.user.client.rpc.SerializationException: Type 'net.your.class' was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be serialized.: instance = net.your.class@9c7edce
        at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:619)
    

提交回复
热议问题