After updating my GWT 2.7 application to GWT 2.8.1 I receive the following exception:
com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException: The response could not be deserialized
Caused by: com.google.gwt.user.client.rpc.SerializationException: /my/path/to/a/file.pdf
. This path is stored in the path variable of MyClass
:
import java.util.ArrayList;
import java.util.List;
import com.google.gwt.user.client.rpc.IsSerializable;
public class MyClass implements IsSerializable {
private Integer id;
private String name;
private String path;
private List<String> assetClasses = new ArrayList<>();
private List<String> keywords = new ArrayList<>();
private List<Integer> regions = new ArrayList<>();
public ReportLink() {
// Empty default constructor for GWT serialization.
}
...getters + setters following
}
As you can see I'm implementing IsSerializable
. Moreover I have an empty constructor (which is probably the most popular reason for this exception ;-)) and the class is located in the shared folder (referenced in the *.gwt.xml).
I set the data like this from a database query:
myClass.setName(resultSet.getString("name"));
myClass.setPath(resultSet.getString("path"));
String keywords = resultSet.getString("keywords");
myClass.setKeywords(Arrays.asList(keywords.split("\\s*,\\s*")))
...
and add different MyClass
to a List<MyClass>
. Afterwards two of these lists are added to a map and returned:
Map<String, List<MyClass>> map = new HashMap<>();
map.put("A", a);
map.put("B", b);
return map;
This is only happening on the server after compilation. In SuperDevMode everything works fine. Any idea?
I already deleted the classes and deploy folders, did a project + gwt-unit-cache clean and recompiled the project multiple times but the exception still occurs.
I'm also wondering why the exception explicitly logs the String path
which should be serializable without problems?!
The reason was an old version of gwt-servlet.jar
with another name in the WEB-INF/lib
folder beside the new gwt-servlet.jar
of version 2.8.1. Due to that it was not obvious on the first sight. Embarrassing, but perhaps it reminds others to double-check...