We are facing a strange problem during compilation when we want to send a custom bean TestBean
from server to client in Vaadin 7.5.4 using ClientRpc
.
public class TestBean implements Serializable {
private TestDto dto;
public TestDto getDto() {
return dto;
}
public void setDto(TestDto dto) {
this.dto = dto;
}
}
public class TestDto implements Serializable {
private String message;
public TestDto(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
During compliation we get the following error:
[ERROR]
Rebind result ‘my.test.TestDto’ has no default (zero argument) constructors
Because TestDto
does not have a default (zero argument) constructor, we have implemented a CustomFieldSerializer
and placed it in the same package of TestDto
. Unfortunately, our custom serializer seems not to be considered by the vaadin compiler.
public final class TestDto_CustomFieldSerializer extends CustomFieldSerializer<TestDto> {
public static void deserialize(SerializationStreamReader streamReader, TestDto instance) {
// No fields
}
public static TestDto instantiate(SerializationStreamReader streamReader) throws SerializationException {
return new TestDto(streamReader.readString());
}
public static void serialize(SerializationStreamWriter streamWriter, TestDto instance) throws SerializationException {
streamWriter.writeString(instance.getMessage());
}
@Override
public void deserializeInstance(SerializationStreamReader streamReader, TestDto instance) throws SerializationException {
deserialize(streamReader, instance);
}
@Override
public boolean hasCustomInstantiateInstance() {
return true;
}
@Override
public TestDto instantiateInstance(SerializationStreamReader streamReader) throws SerializationException {
return instantiate(streamReader);
}
@Override
public void serializeInstance(SerializationStreamWriter streamWriter, TestDto instance) throws SerializationException {
serialize(streamWriter, instance);
}
}
We have also found out that all built-in CustomFieldSerializer
are working fine, but compilation always fails, when we use custom implementations and place them in the corresponding packages. In a separate test case, we have tried to send a collection HashBasedTable
of guava-gwt
from client to server. This class is also missing a default (zero argument) constructor, but the CustomFieldSerializer
implementation HashBasedTable_CustomFieldSerializer
is provided in the same package. During compilation, we get the same error:
[ERROR]
Rebind result ‘com.google.common.collect.HashBasedTable’ has no default (zero argument) constructors.
Refering to the GWT documentation, this seems to be a proper solution, when classes are missing a default (zero argument) constructor:
http://www.gwtproject.org/doc/latest/DevGuideServerCommunication.html#DevGuideCustomSerialization
Has anybody an idea what we are making wrong?