google-code-export / gwt-dispatch

Automatically exported from code.google.com/p/gwt-dispatch
1 stars 0 forks source link

BatchAction cannot be serialized #8

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
BatchAction uses final fields.

This is not supported by GWT RPC serialization.

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

Original issue reported on code.google.com by pjul...@gmail.com on 21 Sep 2009 at 3:23

GoogleCodeExporter commented 9 years ago
Should be fixed by r88.

Original comment by Bitmei...@gmail.com on 16 Oct 2009 at 3:06

GoogleCodeExporter commented 9 years ago

Original comment by Bitmei...@gmail.com on 21 Oct 2009 at 9:21

GoogleCodeExporter commented 9 years ago
few more classes as well:

java.util.Vector<? extends java.lang.Object>
   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<T>
         Type 'net.customware.gwt.dispatch.shared.AbstractSimpleResult<T>' was not 
serializable and has no concrete serializable subtypes
      net.customware.gwt.dispatch.shared.AbstractUpdateResult<T>
         Type 'net.customware.gwt.dispatch.shared.AbstractUpdateResult<T>' was not 
serializable and has no concrete serializable subtypes

Original comment by mwaschko...@gmail.com on 10 Nov 2009 at 6:36

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

Original comment by Bitmei...@gmail.com on 12 Nov 2009 at 12:16

GoogleCodeExporter commented 9 years ago
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<T> and 
AbstractUpdateResult<T>.

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

Original comment by mwaschko...@gmail.com on 12 Nov 2009 at 2:35

GoogleCodeExporter commented 9 years ago
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.

Original comment by Bitmei...@gmail.com on 12 Nov 2009 at 2:52

GoogleCodeExporter commented 9 years ago
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.

Original comment by mwaschko...@gmail.com on 12 Nov 2009 at 3:03

GoogleCodeExporter commented 9 years ago
Still getting the following after checking out from subversion (r.108)

java.util.Arrays.ArrayList<? extends java.lang.Object>
   Checking all subtypes of Object which qualify for serialization
      net.customware.gwt.dispatch.shared.AbstractSimpleResult<T>
         Type 'net.customware.gwt.dispatch.shared.AbstractSimpleResult<T>' was not 
serializable and has no concrete serializable subtypes
      net.customware.gwt.dispatch.shared.AbstractUpdateResult<T>
         Type 'net.customware.gwt.dispatch.shared.AbstractUpdateResult<T>' 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

Original comment by mwaschko...@gmail.com on 19 Nov 2009 at 1:21

GoogleCodeExporter commented 9 years ago
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_syste
m_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.

Original comment by mwaschko...@gmail.com on 19 Nov 2009 at 1:40

GoogleCodeExporter commented 9 years ago
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<String>{

    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;
    }

}

Original comment by mwaschko...@gmail.com on 19 Nov 2009 at 2:09

GoogleCodeExporter commented 9 years ago
Here is the other class for completeness sake, and no more error messages, yay!

public class SimpleResult extends AbstractSimpleResult<String>{

    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;
    }

}

Original comment by mwaschko...@gmail.com on 19 Nov 2009 at 2:17

GoogleCodeExporter commented 9 years ago
Is this issue basically resolved then? Can I close it out?

Original comment by Bitmei...@gmail.com on 25 Apr 2010 at 1:46

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

Original comment by Bitmei...@gmail.com on 28 Apr 2010 at 2:37