Im grafting the code from the carstore example into my prototype app and having a strange problem. I can't get the thing to deserialize the json response.
Heres the error:
com.gwtplatform.dispatch.shared.ActionException: Unable to deserialize response.
at com.gwtplatform.dispatch.client.rest.RestResponseDeserializer.getDeserializedResponse(RestResponseDeserializer.java:60)
at com.gwtplatform.dispatch.client.rest.RestResponseDeserializer.deserialize(RestResponseDeserializer.java:38)
at com.gwtplatform.dispatch.client.rest.RestDispatchAsync$1.onResponseReceived(RestDispatchAsync.java:124)
at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:258)
at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:412)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:242)
at sun.reflect.GeneratedMethodAccessor246.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
at java.lang.Thread.run(Unknown Source)
Caused by: com.google.gwt.user.client.rpc.SerializationException: com.google.gwt.json.client.JSONException: "[{"empno":0,"firstName":"Edith","lastName":"Fisher","reportsTo":0}]" represents invalid json data!
at com.gwtplatform.dispatch.client.rest.JsonSerializer.deserialize(JsonSerializer.java:40)
at com.gwtplatform.dispatch.client.rest.RestResponseDeserializer.getDeserializedResponse(RestResponseDeserializer.java:58)
... 29 more
Caused by: com.google.gwt.json.client.JSONException: "[{"empno":0,"firstName":"Edith","lastName":"Fisher","reportsTo":0}]" represents invalid json data!
at name.pehl.piriti.json.client.AbstractJsonReader.read(AbstractJsonReader.java:226)
at com.gwtplatform.dispatch.client.rest.JsonSerializer.deserialize(JsonSerializer.java:37)
... 30 more
My service interface:
@Path(ResourcesPath.JACKSON)
public interface EmployeeService extends RestService {
/**
* calls the get employees service.
*
* @param num
* @return GetResults<Employee>
*/
@GET
Action<GetResults<Employee>> getEmployees(@QueryParam("num") Integer num);
}
The GetResults class:
public class GetResults<T extends Dto> implements Result {
ArrayList<T> results;
@SuppressWarnings("unused")
protected GetResults() {
}
public GetResults(ArrayList<T> results) {
this.results = results;
}
public ArrayList<T> getResults() {
return results;
}
}
the Dto class:
public interface Dto extends IsSerializable {
}
and my entity:
public class Employee implements Dto {
public int empno;
public String firstName;
public String lastName;
public String extension;
public String eMail;
public String officeCode;
public int reportsTo;
public String jobTitle;
/**
* The key provider that provides the unique ID of a contact.
*/
public static final ProvidesKey<Employee> KEY_PROVIDER = new ProvidesKey<Employee>() {
@Override
public Object getKey(Employee item) {
return item == null ? null : item.getEmpno();
}
};
/**
* Example of how to create an instance of a JsonEncoderDecoder for a data
* transfer object.
*
* public interface EmployeeJED extends JsonEncoderDecoder<Employee> {
*
* }
*
* @param empno
* @param firstName
* @param lastName
* @param extension
* @param eMail
* @param officeCode
* @param reportsTo
* @param jobTitle
*/
public Employee(
int empno,
String firstName,
String lastName,
String extension,
String eMail,
String officeCode,
int reportsTo,
String jobTitle) {
this.setEmpno(empno);
this.setFirstName(firstName);
this.setLastName(lastName);
this.setExtension(extension);
this.seteMail(eMail);
this.setOfficeCode(officeCode);
this.setReportsTo(reportsTo);
this.setJobTitle(jobTitle);
}
public Employee(int empno, String firstName, String lastName, int reportsTo) {
this.setEmpno(empno);
this.setFirstName(firstName);
this.setLastName(lastName);
this.setReportsTo(reportsTo);
}
and for good measure, my caller from the presenter
@Override
protected void onReveal() {
// ActionBarVisibilityEvent.fire(this, true);
// ChangeActionBarEvent.fire(this, Arrays.asList(ActionType.ADD), true);
dispatcher.execute(employeeService.getEmployees(1), new AbstractAsyncCallback<GetResults<Employee>>() {
@Override
public void onSuccess(GetResults<Employee> result) {
getView().displaySearchGrid(result.getResults());
}
});
}
and my module file:
<module rename-to='gwtptabsample'>
<!-- Inherit rest dispatch stuff. Order matters here, rest needs to be before mvp -->
<inherits name="com.gwtplatform.dispatch.DispatchRest" />
<inherits name="com.gwtplatform.mvp.MvpWithEntryPoint" />
<!-- GinUiBinder allows injecting widgets in UiBinder -->
<inherits name="com.google.gwt.uibinder.GinUiBinder" />
<!-- debugging
<inherits name="com.google.gwt.logging.Logging"/>
<inherits name="com.google.gwt.user.Debug"/>
<set-property name="gwt.logging.logLevel" value=INFO/>
<set-property name="gwt.logging.enabled" value="TRUE"/> -->
<!-- Inherit the default GWT style sheet. You can change -->
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<inherits name="com.google.gwt.user.theme.dark.Dark" />
<!-- Specify the paths for translatable code -->
<source path="client" />
<source path="shared"/>
<extend-configuration-property name="gin.ginjector.modules"
value="com.gwtplatform.samples.tab.client.gin.ClientModule" />
<set-configuration-property name="gin.ginjector.extensions"
value="com.gwtplatform.samples.tab.client.gin.GinjectorExtension" />
</module>
The number in the parameter is just telling my service how many random employees to generate. I get the same error if i call one result or multiple. Again, this is based on the model that is used in the CarStore example in the GWTP source tree. Any ideas why this isn't working?