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 solved my problem by updating
GwtRpcController
according to this. Now deserialization works good without using any transfer object. WorkingGwtRpcController
below.All, Spent alot of time with this, and I have a different solution. I was using a very simple setup and my POJOs were really nothing more that members and a CTOR.
I recreated a new GWT project and added my stuff back into the new project, adding each POM.xml dependency back in. What I found was the maven compiler was set too high. I had copied this in from another project not thinking about it... GWT client side is pretty much only 1.5, maybe 1.6 compatible... so these settings need to be set to 1.5, not 1.7