Thursday, November 21, 2013

GWT Serialization Broken?

I have a fairly simple case. I have also simplified the names to make it easier to read (see below).

 

I have an enum and a user-defined class which uses this enum, as well as a String.

 

According to GWT:

·        The enum should be serializable.

·        The user-defined class should be serializable because:

o   It directly implements Serializable.

o   It's non-final, non-transient instance fields are serializable:

§  The enum is serializable.

§  The String is serializable.

o   It has a default (zero argument) constructor.

 

Despite conforming to these rules, an attempt to use these classes results in the following error:

 

 

SEVERE: Exception while dispatching incoming RPC call com.google.gwt.user.client.rpc.SerializationException: Type 'com.arcsight.arcmc.ui.common.service.shared.data.Bar 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 = com.arcsight.arcmc.ui.common.service.shared.data.Bar @4c19cc84

 

 

Simple case.

 

GWT bungles it.

 

Is it broken?

 

Paul

 

A type is serializable and can be used in a service interface if one of the following is true:

  • The type is primitive, such as char, byte, short, int, long, boolean, float, or double.
  • The type an instance of the String, Date, or a primitive wrapper such as Character, Byte, Short, Integer, Long, Boolean, Float, or Double.
  • The type is an enumeration. Enumeration constants are serialized as a name only; none of the field values are serialized.
  • The type is an array of serializable types (including other serializable arrays).
  • The type is a serializable user-defined class.
  • The type has at least one serializable subclass.
  • The type has a Custom Field Serializer

A user-defined class is serializable if all of the following apply:

  1. It is assignable to IsSerializable or Serializable, either because it directly implements one of these interfaces or because it derives from a superclass that does
  2. All non-final, non-transient instance fields are themselves serializable, and
  3. As of GWT 1.5, it must have a default (zero argument) constructor (with any access modifier) or no constructor at all.

 

 

Foo.java

 

public enum Foo {

    A, B, C;

}

 

 

 

Bar.java

 

public class Bar implements Serializable {

private static final long serialVersionUID = 604131643709466885L;

private Foo foo;

private String s;

 

public Bar() {

}

 

public Foo getFoo() {

          return foo;

}

public void setFoo(Foo foo) {

          this.Foo = foo;

}

public String getS() {

          return s;

}

public void setS(String s) {

          this.s = s;

}

}

 

 

 

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment