开发者

serialization problem in gwt

I have read that:

GWT serialization issue

but there is no the solution.

my packages are:

package gwt.web package gwt.web.client; etc...

and i have package models

Where is located my class 'models.Word'

As you can see this class is located not int gwt.cleint, but it should not be there, it is not client side class.

this class has default constructor, so this is not issue.

I have exception:

Service method 'public abstract java.util.List gwt.web.client.WordService.getWords(java.lang.String)' threw an unexpected exception: com.google.gwt.user.client.rpc.SerializationException: Type 'models.Word' 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 = Word[null]

in my App.gwt.xml:

<!-- Specify the paths for translatable code                    -->
<source path='models'/>

so this poits to my class. so, it should not be the issue as well.

The question: how to handle that? I need use my models classes to pass its by ajax by Services.

My Class is seria开发者_如何学Golizable (implements that interface).

This class is part of my code. This class used in RPC:

@RemoteServiceRelativePath("wordServiceImpl")
public interface WordService extends RemoteService {
    public List<Word> getWords(String langCode);
}


One key thing to keep in mind is that GWT optimizes and does not serialize all classes if not required.

If your class is not part of any RPC call (i.e. classes used in RPC call don't have this class object as a data member), GWT would not serialize this class as it assumes its not needed.

Is this the case with your code? In that case, just add a fake data member of this class to a class used in RPC

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜