Be sure your post includes:
1. SmartClient Version: v9.0_2013-07-03/LGPL Development Only (built 2013-07-03)
2. Firefox 24.0
Error:
I had another two previously working SmartGWT apps which called RESTful SpringMVC controllers. They received JSON and sent JSON databack successfully, and SmartGWT at one point was happy to receive this properly formatted custom data. However, now this new app is broken, and the old apps seem broken also, but I can't find what the issue is.
The back-end SpringMVC controller is Unit Tested and works. It uses the Jackson 2.0 mapper to translate from objects to JSON and back again. The controller is sending back a UserEntity which looks like:
I have unit tested this JSON with Jackson Mapper 2.0 from a JSON String to UserEntity to UserDTO to String and back again. This all looks like it works. I also used the JSON.encode to translate from a JavaScriptObject to a String and that JSON string data can also be translated into an object. Finally, I tested this JSON data against several online JSON validators to make sure that the JSON was correct.
In the RestDataSource I double-checked that the dataSourc field names match those in the JSON.
As for the DSReponse itself, within the transformResponse itself I have the following:
I am looking at the data for the response, which I don't think I have any control over. I thought the RestDataSource created that correctly, and this is what I can is there:
So, if the response should be correct because I have no control over it, and if my JSON is correct, then I am at a loss as to what the issue is.
I have installed the SmartClient Developer Tools, and I pulled it up. I did turn on the tracking of RPC's and unfortunately, this tracking is not getting called, and I am not able to see the request/response at all.
I think I've done my due diligence here, and I have researched this, even comparing my current code to other previously working projects. However, this projects are now reporting the same error with their JSON data, and I have checked to make sure that JSON is correct also.
Any help would be much appreciated. Thanks!
1. SmartClient Version: v9.0_2013-07-03/LGPL Development Only (built 2013-07-03)
2. Firefox 24.0
Error:
Code:
15:04:20.592 [ERROR] [SoccerAdmin] 15:04:20.590:XRP7:WARN:RestDataSource:restLoginDS:RestDataSouce transformResponse(): JSON response text does not appear to be in standard response format. com.smartgwt.client.core.JsObject$SGWT_WARN: 15:04:20.590:XRP7:WARN:RestDataSource:restLoginDS:RestDataSouce transformResponse(): JSON response text does not appear to be in standard response format. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105) 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.invokeNativeVoid(ModuleSpace.java:299) at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107) at com.smartgwt.client.data.DataSource.transformResponse(DataSource.java) at com.companyname.products.soccer.admin.client.datasource.LoginDataSource.transformResponse(LoginDataSource.java:273) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) 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.GeneratedMethodAccessor56.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) 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(Thread.java:662)
The back-end SpringMVC controller is Unit Tested and works. It uses the Jackson 2.0 mapper to translate from objects to JSON and back again. The controller is sending back a UserEntity which looks like:
Code:
{ "userId":1, "username":"tholmes", "password":"password", "active":true, "fullname":"Thomas Holmes", "birthdate":"1960-01-01", "email":"tom@tomholmes.net", "cellPhone":"111-222-1234", "updatedBy":1, "updatedDate":"2013-01-01", "createdBy":1, "createdDate":"2013-01-01", "securityQuestion1":"first car", "securityAnswer1":"prius" }
In the RestDataSource I double-checked that the dataSourc field names match those in the JSON.
Code:
protected void init() { System.out.println("init: START"); setDataFormat(DSDataFormat.JSON); setJsonRecordXPath("/"); // set the values for the datasource userIdField = new DataSourceIntegerField("userId", Constants.TITLE_USER_ID); userIdField.setPrimaryKey(true); userIdField.setCanEdit(false); usernameField = new DataSourceTextField("username", Constants.TITLE_USER_USERNAME); usernameField.setCanEdit(false); passwordField = new DataSourceTextField("password", Constants.TITLE_USER_PASSWORD); passwordField.setCanEdit(false); userActiveField = new DataSourceBooleanField("active", Constants.TITLE_USER_ACTIVE); fullnameField = new DataSourceTextField("fullname", Constants.TITLE_USER_FULLNAME); birthdateField = new DataSourceDateField("birthdate", Constants.TITLE_USER_BIRTHDATE); emailField = new DataSourceTextField("email", Constants.TITLE_USER_EMAIL); cellPhoneField = new DataSourceTextField("cellPhone", Constants.TITLE_USER_CELL_PHONE); securityQuestion1Field = new DataSourceTextField("securityQuestion1", Constants.TITLE_USER_SECURITY_QUESTION_1); securityAnswer1Field = new DataSourceTextField("securityAnswer1", Constants.TITLE_USER_SECURITY_ANSWER_1); updatedByField = new DataSourceIntegerField("updatedBy", Constants.TITLE_USER_UPDATED_BY); updatedDateField = new DataSourceDateField("updatedDate", Constants.TITLE_USER_UPDATED_DATE); createdByField = new DataSourceIntegerField("createdBy", Constants.TITLE_USER_CREATED_BY); createdDateField = new DataSourceDateField("createdDate", Constants.TITLE_USER_CREATED_DATE); System.out.println("init: FINISH"); setFields(userIdField, usernameField, passwordField, userActiveField, emailField, cellPhoneField, fullnameField, birthdateField, securityQuestion1Field, securityAnswer1Field, updatedByField, updatedDateField, createdByField, createdDateField); // setFetchDataURL(getServiceRoot() + "/userId/{id}"); // setFetchDataURL(getServiceRoot() + "/contactId/{id}"); setAddDataURL(getServiceRoot() + "/create"); setUpdateDataURL(getServiceRoot() + "/update"); setRemoveDataURL(getServiceRoot() + "/remove/{id}"); }
Code:
@Override protected void transformResponse(DSResponse response, DSRequest request, Object jsonData) { System.out.println("LoginDataSource: transformResponse: START"); JavaScriptObject jsObj = (JavaScriptObject) jsonData; String jsoText1 = JSON.encode(jsObj); System.out.println("LoginDataSource: transformResponse: jsoText1=" + jsoText1); System.out.println("LoginDataSource: transformResponse: jsonData=" + jsonData.getClass()); for (String attr : response.getAttributes()) { System.out.println("LoginDataSource: transformResponse: attr=" + attr + " value=" + response.getAttribute(attr)); } super.transformResponse(response, request, jsonData); }
Code:
LoginDataSource: transformResponse: jsonData=class com.google.gwt.core.client.JavaScriptObject$ LoginDataSource: transformResponse: attr=data value=[object Object] LoginDataSource: transformResponse: attr=startRow value=0 LoginDataSource: transformResponse: attr=status value=0 LoginDataSource: transformResponse: attr=endRow value=1 LoginDataSource: transformResponse: attr=totalRows value=1 LoginDataSource: transformResponse: attr=httpResponseCode value=200 LoginDataSource: transformResponse: attr=transactionNum value=0 LoginDataSource: transformResponse: attr=clientContext value=null LoginDataSource: transformResponse: attr=httpHeaders value=[object Object] LoginDataSource: transformResponse: attr=context value=[object Object]
I have installed the SmartClient Developer Tools, and I pulled it up. I did turn on the tracking of RPC's and unfortunately, this tracking is not getting called, and I am not able to see the request/response at all.
I think I've done my due diligence here, and I have researched this, even comparing my current code to other previously working projects. However, this projects are now reporting the same error with their JSON data, and I have checked to make sure that JSON is correct also.
Any help would be much appreciated. Thanks!
Comment