I am working on an application GWT which searches files on different servers. I have my searching code in the server package in a class called Search. To help Search locate the servers, I have the server locations in a class called Login, which is in the shared package. Login contains Authentication objects, which store the information for an individual server.
The code to call Search is as follows:
SearchInterfaceAsync search = GWT.create(SearchInterface.class);
AsyncCallback<Void> callback = new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable caught) {
System.out.println("Error: " + caught.getMessage());
}
@Override
public void onSuccess (Void results) {
System.out.println("Success!");
}
};
search.initialize(serverName, login, callback);
search.searchServers(search, variousSearchParameters, callback);
When I run the program and try to search, the program prints Error: could not get type signature for class [Lcom.example.test.shared.Authentication;
.
The code for Authentication is as follows:
public class Authentication implements Serializable {
private static final long serialVersionUID = 5326256122438445301L;
private String server;
private String userName;
private String password;
public Authentication(String serverName){
server = serverName;
}
public Authentication(String serverName, String user, String pass){
server = serverName;
userName = user;
password = pass;
}
public String getServer(){
return server;
}
public String getUserName(){
return userName;
}
public String getPassword() {
return password;
}
}
I have tried changing the type declaration, adding Serialization, switching to IsSerializible, and nothing works!
In case it helps others, these are the causes of this error I've run into recently. Sending objects from client to server:
public MyObject() {}
Object
(Object can't be serialized)Serializable
interface<?>
causing issues).These errors in GWT can show up as simply "500 server errors" which is hard to debug.
Hope that saves some hair-pulling.
I have tried changing the type declaration, adding Serialization, switching to IsSerializible, and nothing works!
You missed one: you must have a default (zero-arg) constructor, or a new instance can't be created. The deserialization process creates an object then assigns the fields.
I believe you can make this constructor protected so that no developer can accidentally use it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With