I'm using GWT (2.4) with Spring integrated as in this article. I have problem with getting list of User from database (Hibernate) and populate DataGrid with it. When i call greetingService.allUsers()
method, I'm getting error (onFailure()):
com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException: The response could not be deserialized
Anybody helps with that? Below some pieces of code. Full working project is here.
public void onModuleLoad() {
// ...
greetingService.allUsers(
new AsyncCallback<List<User>>(){
@Override
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
@Override
public void onSuccess(List<User> result) {
GWT.log("SIZE: "+result.size());
dataGrid.setRowData(result);
}
}
);
// ...
}
GreetingServiceImpl
@Override
public List<User> allUsers() {
return userDAO.findAll();
}
User
@Entity
@Table(name = "users")
public class User implements Serializable, IsSerializable {
@Id
private Long id;
// only Strings and one Date
private String login;
private String password;
private String firstname;
private String lastname;
private Date date;
}
I had that error when using guava-gwt with scope "provided". In order to satisfy the dependencies during runtime, I added google-collections. GWT client couldn't deserialize those.
Solution: remove dependency google-collections, and stick with guava.
To problems with serializable objects, you can try this check list:
Font: http://isolasoftware.it/2011/03/22/gwt-serialization-policy-error/
I am working in a team with mature software which one day stopped working for me due to this error. The rest of the team was fine. We tried any number of things to fix it. Eventually, we reinstalled IntelliJ and that fixed it.
I would try a couple of things.
You are not doing anything more complicated that cannot be serialized so you should be fine with that.
Documentation for IncompatibleRemoteServiceException says:
In your case is the last point, you have a type which cannot be serialized and deserialized, that's a your
User
class is one of them. You should have one transfer object which implementscom.google.gwt.user.client.rpc.IsSerializable
interface for transmitting the User object across the network. For further information see: Compatibility with the Java Language and Libraries. GWT RPC method parameters and return types must be transmitted across a network between client and server applications and therefore they must be serializable.Sometimes this error can be due to outdated/corrupted client-side files/cache (There is no server side error message in this case). I just ran "rebuild module" in IntelliJ and it was fine again.