执行RPC GWT时出现SerializationPolicy错误
在我的Google Web Toolkit项目中,我遇到以下错误: 类型“com.example.model.User_$$\u javassist_1”未包含在此可由此SerializationPolicy序列化的类型集中,或者无法加载其类对象。出于安全目的,将不会序列化此类型。:instance=com.example.model。User@1dc2baa 这一错误的可能原因是什么执行RPC GWT时出现SerializationPolicy错误,gwt,rpc,Gwt,Rpc,在我的Google Web Toolkit项目中,我遇到以下错误: 类型“com.example.model.User_$$\u javassist_1”未包含在此可由此SerializationPolicy序列化的类型集中,或者无法加载其类对象。出于安全目的,将不会序列化此类型。:instance=com.example.model。User@1dc2baa 这一错误的可能原因是什么 这个代码看起来不错。尝试重新启动开发服务器。是否包含所有代码?您最近升级了GWT吗?您使用ja
这个代码看起来不错。尝试重新启动开发服务器。是否包含所有代码?您最近升级了GWT吗?您使用javassist的目的是什么?这似乎是在运行时修改/创建类,这意味着RPC序列化机制无法通过连接正确发送,因为它现在的格式与GWT编译客户端反序列化代码时的格式不同。当我从projet类中删除用户属性时,它工作正常。但是对于用户,我有同样的错误。我找到了解决方案,我必须使用DTO,谢谢你们
package com.example.model;
import java.io.Serializable;
public class User implements Serializable {
private Integer id;
private String username;
private String fullname;
private String firstname;
private String lastname;
private String password;
private String picture;
private String adresse;
private String email;
private Integer telephone;
private Integer fax;
private String role;
public User() {
}
public User(Integer id, String username, String fullname, String firstname,
String lastname, String password, String picture, String adresse,
String email, Integer telephone, Integer fax, String role) {
this.id = id;
this.username = username;
this.fullname = fullname;
this.firstname = firstname;
this.lastname = lastname;
this.password = password;
this.picture = picture;
this.adresse = adresse;
this.email = email;
this.telephone = telephone;
this.fax = fax;
this.role = role;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getFullname() {
return fullname;
}
public void setFullname(String fullname) {
this.fullname = fullname;
}
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getPicture() {
return picture;
}
public void setPicture(String picture) {
this.picture = picture;
}
public String getAdresse() {
return adresse;
}
public void setAdresse(String adresse) {
this.adresse = adresse;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Integer getTelephone() {
return telephone;
}
public void setTelephone(Integer telephone) {
this.telephone = telephone;
}
public Integer getFax() {
return fax;
}
public void setFax(Integer fax) {
this.fax = fax;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
}
package com.example.model;
import java.io.Serializable;
import java.util.Date;
public class Projet implements Serializable {
private Integer id;
private User user;
private String name;
private String description;
private String abrevation;
private Date dateDebut;
private Date dateFin;
private Date realDateDeb;
private Date realDateFin;
private String icone;
private Double budget;
private Double tauxTva;
public Projet() {
}
public Projet(Integer id, User user,
String name, String description,
String abrevation, Date dateDebut, Date dateFin, Date realDateDeb,
Date realDateFin, String icone, Double budget, Double tauxTva) {
this.id = id;
this.user = user;
this.name = name;
this.description = description;
this.abrevation = abrevation;
this.dateDebut = dateDebut;
this.dateFin = dateFin;
this.realDateDeb = realDateDeb;
this.realDateFin = realDateFin;
this.icone = icone;
this.budget = budget;
this.tauxTva = tauxTva;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getAbrevation() {
return abrevation;
}
public void setAbrevation(String abrevation) {
this.abrevation = abrevation;
}
public Date getDateDebut() {
return dateDebut;
}
public void setDateDebut(Date dateDebut) {
this.dateDebut = dateDebut;
}
public Date getDateFin() {
return dateFin;
}
public void setDateFin(Date dateFin) {
this.dateFin = dateFin;
}
public Date getRealDateDeb() {
return realDateDeb;
}
public void setRealDateDeb(Date realDateDeb) {
this.realDateDeb = realDateDeb;
}
public Date getRealDateFin() {
return realDateFin;
}
public void setRealDateFin(Date realDateFin) {
this.realDateFin = realDateFin;
}
public String getIcone() {
return icone;
}
public void setIcone(String icone) {
this.icone = icone;
}
public Double getBudget() {
return budget;
}
public void setBudget(Double budget) {
this.budget = budget;
}
public Double getTauxTva() {
return tauxTva;
}
public void setTauxTva(Double tauxTva) {
this.tauxTva = tauxTva;
}
}
<hibernate-mapping>
<class name="com.example.model.Projet" table="PROJET" lazy="true">
<id name="id" column="PROJET_ID">
<generator class="native"/>
</id>
<property name="name"/>
<property name="description"/>
<property name="abrevation"/>
<property name="dateDebut"/>
<property name="dateFin"/>
<property name="realDateDeb"/>
<property name="realDateFin"/>
<property name="icone"/>
<property name="budget"/>
<property name="tauxTva"/>
<!--
-->
<many-to-one name="user" class="com.example.model.User" fetch="select">
<column name="USER_ID" not-null="true" />
</many-to-one>
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="com.example.model.User" table="USER" lazy="true">
<id name="id" column="USER_ID">
<generator class="native"/>
</id>
<property name="username"/>
<property name="fullname"/>
<property name="firstname"/>
<property name="lastname"/>
<property name="password"/>
<property name="picture"/>
<property name="adresse"/>
<property name="email"/>
<property name="telephone"/>
<property name="fax"/>
<property name="role"/>
</class>
</hibernate-mapping>