GWT 序列化 - class 没有可实例化的子类型
GWT Serialization - class has no instantiable subtypes
我正在尝试序列化此对象 (OperatorDTO),以便我可以使用 RPC 将它从我的服务器端发送到客户端。我已经阅读了有关此主题的其他帖子,但我不明白为什么我做的事情与其他人不同。
当我 运行 我的项目发生这个错误
Compiling module edu.example.RPCExample
Computing all possible rebind results for 'edu.example.client.service.ExampleService'
Rebinding edu.example.client.service.ExampleService
Invoking generator com.google.gwt.user.rebind.rpc.ServiceInterfaceProxyGenerator
Generating client proxy for remote service interface 'edu.example.client.service.ExampleService'
[ERROR] 'edu.example.client.models.OperatorDTO' has no instantiable subtypes
[ERROR] Errors in 'edu/example/client/service/ExampleServiceClientImpl.java'
[ERROR] Line 18: Failed to resolve 'edu.example.client.service.ExampleService' via deferred binding
Unification traversed 16362 fields and methods and 1526 types. 1494 are considered part of the current module and 1494 had all of their fields and methods traversed.
[ERROR] Compiler returned false
[WARN] recompile failed
[WARN] continuing to serve previous version
我不明白为什么我在实现 io.serializable 并且只在class。我在 class 中使用的东西在序列化时是否不允许使用?
package edu.example.client.models;
import java.io.Serializable;
public final class OperatorDTO implements Serializable
{
private static final long serialVersionUID = 1L;
private final int ID_MINIMUM_VALUE = 11;
private final int ID_MAXIMUM_VALUE = 99;
private final int RANK_MINIMUM_VALUE = -1;
private final int RANK_MAXIMUM_VALUE = 1;
private final int NAME_MINIMUM_LENGTH = 2;
private final int PASSWORD_MINIMUM_LENGTH = 6;
private final int NUMBER_OF_SPECIAL_CHARACTERS = 3;
private int oprID;
private String oprNavn;
private String ini;
private String cpr;
private String password;
private int rank;
public OperatorDTO(int oprID, String oprNavn, String ini, String cpr, String password, int rank) {
setOprID(oprID);
setName(oprNavn);
setIni(ini);
setCpr(cpr);
setPassword(password);
setRank(rank);
}
public OperatorDTO(int oprID, String oprNavn, String ini, String cpr, String password) {
setOprID(oprID);
setName(oprNavn);
setIni(ini);
setCpr(cpr);
setPassword(password);
}
public void setIni(String ini) {
this.ini = ini;
}
public String getIni() {
return this.ini;
}
public void setRank(int rank) {
if(rank >= RANK_MINIMUM_VALUE && rank <= RANK_MAXIMUM_VALUE)
this.rank = rank;kravende");
}
public int getRank() {
return this.rank;
}
public void setOprID(int oprID) {
if(oprID >= ID_MINIMUM_VALUE && oprID <= ID_MAXIMUM_VALUE)
this.oprID = oprID;
}
public int getOprID() {
return this.oprID;
}
public void setName(String name) {
if(name != null)
if(name.length() >= NAME_MINIMUM_LENGTH)
this.oprNavn = name;
}
public void setCpr(String cpr) {
this.cpr = cpr;
}
public void setPassword(String password) {
if(valPass(password))
this.password = password;
}
public String getName() {
return this.oprNavn;
}
public String getCpr() {
return this.cpr;
}
public String getPassword() {
return this.password;
}
private boolean valPass(String pass) {
if(pass.length() < PASSWORD_MINIMUM_LENGTH)
return false;
byte lowerCase = 0;
byte upperCase = 0;
byte digit = 0;
byte specialChar = 0;
char[] passChar = pass.toCharArray();
for (char c : passChar) {
if(Character.isLowerCase(c))
lowerCase = 1;
else if(Character.isUpperCase(c))
upperCase = 1;
else if(Character.isDigit(c))
digit = 1;
else if(c == 46 || c == 45 || c == 95 || c == 43 || c ==33 || c == 63 || c == 61)
specialChar = 1;
else
return false;
}
return (lowerCase + upperCase + digit + specialChar) >= NUMBER_OF_SPECIAL_CHARACTERS;
}
@Override
public String toString() {
return "OperatorDTO{" + "oprID=" + oprID + ", oprNavn=" + oprNavn + ", ini=" + ini + ", cpr=" + cpr + ", password=" + password + ", rank=" + rank + '}';
}
}
提前感谢您的帮助!
我正在尝试序列化此对象 (OperatorDTO),以便我可以使用 RPC 将它从我的服务器端发送到客户端。我已经阅读了有关此主题的其他帖子,但我不明白为什么我做的事情与其他人不同。
当我 运行 我的项目发生这个错误
Compiling module edu.example.RPCExample
Computing all possible rebind results for 'edu.example.client.service.ExampleService'
Rebinding edu.example.client.service.ExampleService
Invoking generator com.google.gwt.user.rebind.rpc.ServiceInterfaceProxyGenerator
Generating client proxy for remote service interface 'edu.example.client.service.ExampleService'
[ERROR] 'edu.example.client.models.OperatorDTO' has no instantiable subtypes
[ERROR] Errors in 'edu/example/client/service/ExampleServiceClientImpl.java'
[ERROR] Line 18: Failed to resolve 'edu.example.client.service.ExampleService' via deferred binding
Unification traversed 16362 fields and methods and 1526 types. 1494 are considered part of the current module and 1494 had all of their fields and methods traversed.
[ERROR] Compiler returned false
[WARN] recompile failed
[WARN] continuing to serve previous version
我不明白为什么我在实现 io.serializable 并且只在class。我在 class 中使用的东西在序列化时是否不允许使用?
package edu.example.client.models;
import java.io.Serializable;
public final class OperatorDTO implements Serializable
{
private static final long serialVersionUID = 1L;
private final int ID_MINIMUM_VALUE = 11;
private final int ID_MAXIMUM_VALUE = 99;
private final int RANK_MINIMUM_VALUE = -1;
private final int RANK_MAXIMUM_VALUE = 1;
private final int NAME_MINIMUM_LENGTH = 2;
private final int PASSWORD_MINIMUM_LENGTH = 6;
private final int NUMBER_OF_SPECIAL_CHARACTERS = 3;
private int oprID;
private String oprNavn;
private String ini;
private String cpr;
private String password;
private int rank;
public OperatorDTO(int oprID, String oprNavn, String ini, String cpr, String password, int rank) {
setOprID(oprID);
setName(oprNavn);
setIni(ini);
setCpr(cpr);
setPassword(password);
setRank(rank);
}
public OperatorDTO(int oprID, String oprNavn, String ini, String cpr, String password) {
setOprID(oprID);
setName(oprNavn);
setIni(ini);
setCpr(cpr);
setPassword(password);
}
public void setIni(String ini) {
this.ini = ini;
}
public String getIni() {
return this.ini;
}
public void setRank(int rank) {
if(rank >= RANK_MINIMUM_VALUE && rank <= RANK_MAXIMUM_VALUE)
this.rank = rank;kravende");
}
public int getRank() {
return this.rank;
}
public void setOprID(int oprID) {
if(oprID >= ID_MINIMUM_VALUE && oprID <= ID_MAXIMUM_VALUE)
this.oprID = oprID;
}
public int getOprID() {
return this.oprID;
}
public void setName(String name) {
if(name != null)
if(name.length() >= NAME_MINIMUM_LENGTH)
this.oprNavn = name;
}
public void setCpr(String cpr) {
this.cpr = cpr;
}
public void setPassword(String password) {
if(valPass(password))
this.password = password;
}
public String getName() {
return this.oprNavn;
}
public String getCpr() {
return this.cpr;
}
public String getPassword() {
return this.password;
}
private boolean valPass(String pass) {
if(pass.length() < PASSWORD_MINIMUM_LENGTH)
return false;
byte lowerCase = 0;
byte upperCase = 0;
byte digit = 0;
byte specialChar = 0;
char[] passChar = pass.toCharArray();
for (char c : passChar) {
if(Character.isLowerCase(c))
lowerCase = 1;
else if(Character.isUpperCase(c))
upperCase = 1;
else if(Character.isDigit(c))
digit = 1;
else if(c == 46 || c == 45 || c == 95 || c == 43 || c ==33 || c == 63 || c == 61)
specialChar = 1;
else
return false;
}
return (lowerCase + upperCase + digit + specialChar) >= NUMBER_OF_SPECIAL_CHARACTERS;
}
@Override
public String toString() {
return "OperatorDTO{" + "oprID=" + oprID + ", oprNavn=" + oprNavn + ", ini=" + ini + ", cpr=" + cpr + ", password=" + password + ", rank=" + rank + '}';
}
}
提前感谢您的帮助!