"Class Type' was not included in the set of types which can be serialized ...

今天做GXT项目遇到这个问题

"Class Type' was not included in the set of types which can be serialized ...

搞了半天没搞清楚原因,好不容易google解决了。

首先,检查自己在web目录下即前台的controller中返回给前台界面代码的bean是继承与gxt model对象的bean。gxt提供了很多种bean model,让你去继承或者实现。

其次,检查这些继承的beanmodel是不是有默认构造函数。

第三,检查这些beanmodel是不是内嵌了list之类的对象,比如gxt提供的Beanmodel这个对象是不支持内嵌list bean

的。除非这个内嵌的list bean对象实现了 BeanModelTag 接口

 

Nested beans are supported when creating BeanModel instances with limited

 * support for nested lists of beans. Any child lists must be defined with

 * java.util.List and must be paramertized with a BeanModelTag class or

 * subclass.

不然很大可能会报NullPoint Exception。

 

最后修正一下,需要检查的步骤:

The problem may have different causes. Here his a complete check list to use for solving the problem:

  1. Verify that the class has a default constructor (without arguments)
  2. Verify that the class implements Serializable or IsSerializable or implements an Interface that extends Serializable or extends a class that implement Serializable
  3. Verify that the class is in a client.* package or …
  4. Verify, if the class is not in client.* package, that is compiled in your GWT xml module definition. By default <source path=”client” /> is present. If your class is in another package you have to add it to source. For example if your class is under domain.* you should add it to xml as <source path=”domain” /> . Be aware that the class cannot belong to server package! More details on GWT page: http://code.google.com/webtoolkit/doc/latest/DevGuideOrganizingProjects.html#DevGuideModuleXml
  5. If you are including the class from another GWT project you have to add the inherits to your xml module definition. For example if your class Foo is in thepackage com.dummy.domain you have to add <inherits name=”com.dummy.domain.Foo”/> to the module definition. More details here: http://code.google.com/webtoolkit/doc/latest/DevGuideOrganizingProjects.html#DevGuideInheritingModules
  6. If you are including the class from another GWT project released as a jar verify that the jar contains also the source code because GWT recompile also the Java source for the classes passed to the Client.

 

 

你可能感兴趣的:(java,gxt)