Return type "object" is not serializable and/or has no serializable subtypes

23 views
Skip to first unread message

Tom

unread,
Jan 4, 2007, 10:41:47 PM1/4/07
to Google Web Toolkit
When I try to use return Proto[] in the RPC Invocation, I got the
compiler error, the error are as following:


Computing all possible rebind results for
'program.client.ajax.MyService'
Rebinding program.client.ajax.MyService
Invoking <generate-with
class='com.google.gwt.user.rebind.rpc.ServiceInterfaceProxyGenerator'/>
Validating service interface 'program.client.ajax.MyService'
Service interface: program.client.ajax.MyService
Service method: public abstract
program.client.Trees.Proto[] getProto()
[ERROR] Return type program.client.Trees.Proto[] is
not serializable and/or has no serializable subtypes
[WARN] Deferred binding result type
'program.client.ajax.MyService' is not instantiable; expect subsequent
failure
[ERROR] Errors in 'C:\Documents and
Settings\user\Desktop\gwt\Program\src\program\client\Async.java'
[ERROR] Line 1: Unable to resolve required rebind dependencies
Output will be written into C:\Documents and
Settings\user\Desktop\gwt\Program\build\www\program.Main
Analyzing permutation #1
[ERROR] Unexpected internal compiler error
java.lang.RuntimeException: Failed to get JNode
at com.google.gwt.dev.jjs.impl.TypeMap.get(TypeMap.java:28)
at
com.google.gwt.dev.jjs.impl.BuildTypeMap$BuildDeclMapVisitor.createParameter(BuildTypeMap.java:494)
at
com.google.gwt.dev.jjs.impl.BuildTypeMap$BuildDeclMapVisitor.mapParameters(BuildTypeMap.java:208)
at
com.google.gwt.dev.jjs.impl.BuildTypeMap$BuildDeclMapVisitor.visit(BuildTypeMap.java:301)
at
org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse(MethodDeclaration.java:178)
at
org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1170)
at
org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:339)
at
com.google.gwt.dev.jjs.impl.BuildTypeMap.createPeersForNonTypeDecls(BuildTypeMap.java:82)
at
com.google.gwt.dev.jjs.impl.BuildTypeMap.exec(BuildTypeMap.java:64)
at
com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.compile(JavaToJavaScriptCompiler.java:251)
at
com.google.gwt.dev.GWTCompiler.realizePermutation(GWTCompiler.java:598)
at
com.google.gwt.dev.GWTCompiler.compilePermutations(GWTCompiler.java:346)
at com.google.gwt.dev.GWTCompiler.distill(GWTCompiler.java:295)
at com.google.gwt.dev.GWTCompiler.run(GWTCompiler.java:629)
at com.google.gwt.dev.GWTCompiler.main(GWTCompiler.java:192)

Below is snippet of the code.

public class Trees extends Composite implements TreeListener{
//some codes of Trees class goes here


//inner class
public static class Proto {
private Proto[] children;
private TreeItem item;
private String text;

public Proto(){

}

public Proto(String text) {
this.text = text;
}


public Proto(String text, Proto[] children) {
this(text);
this.children = children;
}

public Proto[] getChildren() {
return children;
}

public void setChildren(Proto[] children) {
this.children = children;
}

public TreeItem getItem() {
return item;
}

public void setItem(TreeItem item) {
this.item = item;
}

public String getText() {
return text;
}

public void setText(String text) {
this.text = text;
}

}

}

I suspect is because of the "Proto[] children" inside the class Proto.

Do you guys have any idea to help me to solve this problem?

Thanks.

Rgds,
Tom

Tom

unread,
Jan 4, 2007, 11:00:07 PM1/4/07
to Google Web Toolkit
FYI, I did implements IsSerializable in Proto class. But I still get
the compiler error as following:


Computing all possible rebind results for
'program.client.ajax.MyService'
Rebinding program.client.ajax.MyService
Invoking <generate-with
class='com.google.gwt.user.rebind.rpc.ServiceInterfaceProxyGenerator'/>

Analyzing serializability for 304 types
The following types were determined to be unserializable:
program.client.Trees.Proto
Field 'private com.google.gwt.user.client.ui.TreeItem
item' is not of a serializable type nor does that type have
serializable subtypes
program.client.Trees.Proto[]
component type 'program.client.Trees.Proto' is not of
a serializable type nor does it have any serializable subtypes


Validating service interface 'program.client.ajax.MyService'
Service interface: program.client.ajax.MyService
Service method: public abstract
program.client.Trees.Proto[] getProto()
[ERROR] Return type program.client.Trees.Proto[] is
not serializable and/or has no serializable subtypes
[WARN] Deferred binding result type
'program.client.ajax.MyService' is not instantiable; expect subsequent
failure
[ERROR] Errors in 'C:\Documents and

Settings\user\Desktop\gwt\Program\src\program\console\client\Async.java'

[ERROR] Build failed


The snippet of the code:

public class Trees extends Composite implements TreeListener{
//some codes of Trees class goes here


//inner class
public static class Proto implements IsSerializable{

江永源

unread,
Jan 5, 2007, 12:27:36 AM1/5/07
to Google Web Toolkit
i don't know why you are defined a class like this:

public static class Proto {

Message has been deleted

Tom

unread,
Jan 5, 2007, 1:17:54 AM1/5/07
to Google Web Toolkit
I was just testing, and followed the code in KitchenSink.
This is the way it's coded.

Btw, thanks.

Have any idea how to solve?

Tom

江永源

unread,
Jan 5, 2007, 1:29:19 AM1/5/07
to Google Web Toolkit
sorry i can't help you .

you can copy the application ,then modify and test it .
i think you may find the problem.

"Tom 写道:

Ian Petersen

unread,
Jan 5, 2007, 1:42:59 AM1/5/07
to Google-We...@googlegroups.com
> Below is snippet of the code.
>
> public class Trees extends Composite implements TreeListener{
> //some codes of Trees class goes here
>
> //inner class

In my experience, serialization sometimes chokes on inner classes.
Does it fix the problem to move Proto to a top-level class?

> public static class Proto {
> private Proto[] children;
> private TreeItem item;

Is TreeItem IsSerializable? If not, then neither is Proto. Maybe
make the item field transient, like this:

private transient TreeItem item;

I assume TreeItem is a GWT-supplied piece of a tree widget. If so, I
can't see any reason to send one to the server, never mind that the
class probably isn't defined there.

Just my two cents.
Ian

--
Tired of pop-ups, security holes, and spyware?
Try Firefox: http://www.getfirefox.com

Dan Morrill

unread,
Jan 5, 2007, 9:48:14 AM1/5/07
to Google-We...@googlegroups.com

I agree with Ian's comments.  However, even if all that is true, it should not cause a compiler crash.

Tom - if you haven't already, can you enter a bug for us, using this URL:  http://code.google.com/p/google-web-toolkit/issues/list
You can include the code snippet you posted earlier.  It would really help us out!

In the meantime, to get past your problem, you should definitely try Ian's suggestions.

- Dan Morrill
Reply all
Reply to author
Forward
0 new messages