Reputation: 4364
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!
Upvotes: 10
Views: 10941
Reputation: 3343
My problem was a missing 'IsSerializable' flag interface on the class named in the error.
Upvotes: 0
Reputation: 6581
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.
Upvotes: 9
Reputation: 18331
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.
Upvotes: 13