Export to GitHub

gwt-dispatch - issue #8

BatchAction cannot be serialized


Posted on Sep 21, 2009 by Happy Wombat

BatchAction uses final fields.

This is not supported by GWT RPC serialization.

http://code.google.com/p/google-web-toolkit/issues/detail?id=1054

Comment #1

Posted on Oct 16, 2009 by Grumpy Rhino

Should be fixed by r88.

Comment #2

Posted on Oct 21, 2009 by Grumpy Rhino

(No comment was entered for this change.)

Comment #3

Posted on Nov 10, 2009 by Happy Panda

few more classes as well:

java.util.Vector Checking all subtypes of Object which qualify for serialization net.customware.gwt.dispatch.shared.BatchAction Type 'net.customware.gwt.dispatch.shared.BatchAction' was not serializable and has no concrete serializable subtypes net.customware.gwt.dispatch.shared.BatchResult Type 'net.customware.gwt.dispatch.shared.BatchResult' was not serializable and has no concrete serializable subtypes net.customware.gwt.dispatch.shared.AbstractSimpleResult Type 'net.customware.gwt.dispatch.shared.AbstractSimpleResult' was not serializable and has no concrete serializable subtypes net.customware.gwt.dispatch.shared.AbstractUpdateResult Type 'net.customware.gwt.dispatch.shared.AbstractUpdateResult' was not serializable and has no concrete serializable subtypes

Comment #4

Posted on Nov 12, 2009 by Grumpy Rhino

Are you saying that Vector is not serializable? I really need to actually use this class in some code...

Comment #5

Posted on Nov 12, 2009 by Happy Panda

Vector not serializable? Haha. That is just the error message because I use an untyped List somewhere in my RPC code, and gwt treats it as a vector under the covers I guess. But thats not important. Note the 2nd line:

'Checking all subtypes of Object which qualify for serialization'

The GWT compiler is looking for all types that could possibly be put into a list, and not only does BatchAction come up, but so does BatchResult, AbstractSimpleResult and AbstractUpdateResult.

I just thought you would want to address the rpc serialization issues all at once.

Comment #6

Posted on Nov 12, 2009 by Grumpy Rhino

Ah, ok. Well, I would expect that AbstractSimpleResult and AbstractUpdateResult would not, since they are abstract (funnily enough). However, they do not prevent sub-classes from being serializable in any other way, so it must be an issue with BatchResult and BatchAction.

Comment #7

Posted on Nov 12, 2009 by Happy Panda

The abstract class will still be a problem methinks. According to here:

http://code.google.com/p/google-web-toolkit/issues/detail?id=2485

You will have to do a workaround:

Workaround if you have one: Add Serializable to the abstract class, even though it should inherit it from the class it extends

Suggestion: have an RPC test case that passes a List and you will see a similar error message to the one I posted and can validate your update easily. Or, send me an updated jar and I can test if you would like.

Comment #8

Posted on Nov 19, 2009 by Happy Panda

Still getting the following after checking out from subversion (r.108)

java.util.Arrays.ArrayList Checking all subtypes of Object which qualify for serialization net.customware.gwt.dispatch.shared.AbstractSimpleResult Type 'net.customware.gwt.dispatch.shared.AbstractSimpleResult' was not serializable and has no concrete serializable subtypes net.customware.gwt.dispatch.shared.AbstractUpdateResult Type 'net.customware.gwt.dispatch.shared.AbstractUpdateResult' was not serializable and has no concrete serializable subtypes com.refineddata.compliance.client.mvp.presenter.actions.delete.DeleteResult Type 'com.refineddata.compliance.client.mvp.presenter.actions.delete.DeleteResult' was not serializable and has no concrete serializable subtypes

Comment #9

Posted on Nov 19, 2009 by Happy Panda

I reviewed the gwt docs, and GWT requires all client rpc classes to be Serializable.
Every rpc class must implement the serializable interface and an empty constructor, and , as far as I can tell, any abstract class must have at least one implementation.

see: http://code.google.com/webtoolkit/doc/1.6/FAQ_Server.html#Does_the_GWT_RPC_system_sup port_the_use_of_java.io.Serializable

'RPC now generates a serialization policy file during GWT compilation. The serialization policy file contains a whitelist of allowed types which may be serialized. Its name is a strong hash name followed by .gwt.rpc. In order to enable support for java.io.Serializable, the types that your application will send over the wire must be included in the serialization policy whitelist.'

I'm assuming (but don't know the exact details) that GWT wants to put AbstractSimpleResult into the hash with allowable types, but none exist so it throws the exception. I'm going to implement a concrete simple result and let you know what happens.

Comment #10

Posted on Nov 19, 2009 by Happy Panda

Ya, if I add the below into my project, then the AsbstractSimpleResult error message disappears. So as long as there is at least one class to map to, the GWT compiler is satisfied.

I guess you would want to include a class like the below in the source...

public class SimpleResult extends AbstractSimpleResult{

private static final long serialVersionUID = 1L;

private String value;

@SuppressWarnings("unused")
private SimpleResult(){}

public SimpleResult(String value){
    this.value = value;
}

/**
 * @return the value
 */
public String getValue() {
    return value;
}

/**
 * @param value the value to set
 */
public void setValue(String value) {
    this.value = value;
}

}

Comment #11

Posted on Nov 19, 2009 by Happy Panda

Here is the other class for completeness sake, and no more error messages, yay!

public class SimpleResult extends AbstractSimpleResult{

private static final long serialVersionUID = 1L;

private String value;

@SuppressWarnings("unused")
private SimpleResult(){}

public SimpleResult(String value){
    this.value = value;
}

/**
 * @return the value
 */
public String getValue() {
    return value;
}

/**
 * @param value the value to set
 */
public void setValue(String value) {
    this.value = value;
}

}

Comment #12

Posted on Apr 25, 2010 by Grumpy Rhino

Is this issue basically resolved then? Can I close it out?

Comment #13

Posted on Apr 28, 2010 by Grumpy Rhino

Ok, I've added a StringResult and StringUpdateResult to provide concrete implementations of AbstractSimpleResult and AbstractUpdateResult. This should hopefully make the GWT compiler happy.

Status: Fixed

Labels:
Type-Defect Priority-Medium Milestone-Release1.1