3 Replies Latest reply on Aug 15, 2011 6:39 AM by alexmd

    JSONException in RPC

    alexmd

      In the Errai snapshot I downloaded on 2011-08-08 I discovered a problem in RPC services that use serialization. Here is my configuration:

       

      I use Errai 1.3.0 snapshot as mentioned above with GWT 2.3 and SmartGWT Pro 2.4. I configured Errai to use the SimpleDispatcher. The problem occurs in Hosted Mode as well as in Web Mode (which runs on a Tomcat 6.0.24-2ubuntu1.7):

       

      I wrote two simple container classes - TreeNodeContainer and StudyTreeNodeContainer (the code follows at the end of this message). The second is a subclass of the first.

      Furthermore, I created two RPC calls that transfer lists of instances of these container classes from client to server (the first RPC) and back (the second RPC). The lists are defined as java.util.ArrayList<TreeNodeContainer>. A list can contain instances of TreeNodeContainer and StudyTreeNodeContainer together.

       

      The RPC call from client to server works fine. The RPC call, that gets the list of TreeNodeContainer instances from server, does not work with the new snapshot (with Errai 1.2.2 it worked fine too). Now I get the following exception everytime this RPC is invoked:

       

      JSONUtilCli.decodePayload=[{"MethodReply":[{"__EncodedType":"com.microdiscovery.dbwebapp.dataviewer.client.communication.TreeNodeContainer","__ObjectID":"29054640",,"nodeId":1,"nodeName":"Cross-study Analysis","parentNodeId":0},{"__EncodedType":"com.microdiscovery.dbwebapp.dataviewer.client.communication.TreeNodeContainer","__ObjectID":"31669575",,"nodeId":2,"nodeName":"Studies Overview","parentNodeId":1},{"__EncodedType":"com.microdiscovery.dbwebapp.dataviewer.client.communication.TreeNodeContainer","__ObjectID":"30160807",,"nodeId":3,"nodeName":"Study-based Analysis","parentNodeId":0},{"__EncodedType":"com.microdiscovery.dbwebapp.dataviewer.client.communication.TreeNodeContainer","__ObjectID":"5881624",,"nodeId":4,"nodeName":"New Study...","parentNodeId":3},{"__EncodedType":"com.microdiscovery.dbwebapp.dataviewer.client.communication.TreeNodeContainer","__ObjectID":"1106870",,"nodeId":5,"nodeName":"Functional Characterization","parentNodeId":0},{"__EncodedType":"com.microdiscovery.dbwebapp.dataviewer.client.communication.TreeNodeContainer","__ObjectID":"14021375",,"nodeId":6,"nodeName":"New Functional Characterization...","parentNodeId":5},{"__EncodedType":"com.microdiscovery.dbwebapp.dataviewer.client.communication.TreeNodeContainer","__ObjectID":"4489030",,"nodeId":7,"nodeName":"Temporary Storage","parentNodeId":0},{"__EncodedType":"com.microdiscovery.dbwebapp.dataviewer.client.communication.TreeNodeContainer","__ObjectID":"16765422",,"nodeId":8,"nodeName":"Help","parentNodeId":0},{"__EncodedType":"com.microdiscovery.dbwebapp.dataviewer.client.communication.StudyTreeNodeContainer","__ObjectID":"4517618",,"studyId":5,"nodeId":9,"nodeName":"Feedback Circuit among INK4 Tumor Suppressors Constrains Human Glioblastoma Development","parentNodeId":3},{"__EncodedType":"com.microdiscovery.dbwebapp.dataviewer.client.communication.TreeNodeContainer","__ObjectID":"1041495",,"nodeId":10,"nodeName":"New Analysis...","parentNodeId":9},{"__EncodedType":"com.microdiscovery.dbwebapp.dataviewer.client.communication.AnalysisTreeNodeContainer","__ObjectID":"15814929",,"analysisId":"Analysis1","analysisType":"Differential Biomolecule Identification","nodeId":11,"nodeName":"Differential Biomolecule Identification2011-08-11T11:36:12.673+02:00","parentNodeId":9}],"ToSubject":"com.microdiscovery.dbwebapp.dataviewer.client.communication.rpc.MenuTreeService:RPC.getTreeNodes::RespondTo:2"}]

      com.google.gwt.json.client.JSONException: Error parsing JSON: SyntaxError: JSON.parse: expected double-quoted property name

          at com.google.gwt.json.client.JSONParser.throwJSONException(JSONParser.java:91)

          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:167)

          at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:326)

          at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:207)

          at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:132)

          at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)

          at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)

          at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)

          at com.google.gwt.json.client.JSONParser.evaluate(JSONParser.java)

          at com.google.gwt.json.client.JSONParser.parse(JSONParser.java:218)

          at com.google.gwt.json.client.JSONParser.parseStrict(JSONParser.java:87)

          at org.jboss.errai.bus.client.json.JSONUtilCli.decodePayload(JSONUtilCli.java:48)

          at org.jboss.errai.bus.client.framework.ClientMessageBusImpl.procIncomingPayload(ClientMessageBusImpl.java:1148)

          at org.jboss.errai.bus.client.framework.ClientMessageBusImpl.access$7(ClientMessageBusImpl.java:1146)

          at org.jboss.errai.bus.client.framework.ClientMessageBusImpl$5.onResponseReceived(ClientMessageBusImpl.java:524)

          at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)

          at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)

          at sun.reflect.GeneratedMethodAccessor181.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:167)

          at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:326)

          at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:207)

          at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:132)

          at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)

          at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)

          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:214)

          at sun.reflect.GeneratedMethodAccessor179.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:167)

          at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:281)

          at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:531)

          at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)

          at java.lang.Thread.run(Unknown Source)

       

      I think, the problem is the duplication of "," before the "nodeId" key - see this extract from the JSON message:

       

      ...:"com.microdiscovery.dbwebapp.dataviewer.client.communication.TreeNodeContainer","__ObjectID":"29054640",,"nodeId":1,"...

       

      Here are the container classes that are used in the RPCs:

       

      import java.io.Serializable;

      import org.jboss.errai.bus.server.annotations.ExposeEntity;

       

      @ExposeEntity

      public class TreeNodeContainer implements Serializable {

       

        private static final long serialVersionUID = -432859869954816580L;

       

        private int nodeId;

        private String nodeName;

        private int parentNodeId;

       

        public TreeNodeContainer() {

        }

       

        public TreeNodeContainer(int nodeId, String nodeName, int parentNodeId) {

          this.nodeId = nodeId;

          this.parentNodeId = parentNodeId;

          this.nodeName = nodeName;

        }

       

        public int getNodeId() {

          return nodeId;

        }

       

        public void setNodeId(int nodeId) {

          this.nodeId = nodeId;

        }

       

        public String getNodeName() {

          return nodeName;

        }

       

        public void setNodeName(String nodeName) {

          this.nodeName = nodeName;

        }

       

        public int getParentNodeId() {

          return parentNodeId;

        }

       

        public void setParentNodeId(int parentNodeId) {

          this.parentNodeId = parentNodeId;

        }

       

      }

       

      This class has a subclass defined as follows:

       

      import org.jboss.errai.bus.server.annotations.ExposeEntity;

       

      @ExposeEntity

      public class StudyTreeNodeContainer extends TreeNodeContainer {

       

        private static final long serialVersionUID = -3415552168669217572L;

       

        private int studyId;

       

        public StudyTreeNodeContainer() {

          super();

        }

       

        public StudyTreeNodeContainer(int nodeId, String nodeName, int parentNodeId, int studyId) {

          super(nodeId, nodeName, parentNodeId);

          this.studyId = studyId;

        }

       

        public int getStudyId() {

          return studyId;

        }

       

        public void setStudyId(int studyId) {

          this.studyId = studyId;

        }

       

      }

       

      Is there anything that was changed in the new version of Errai that I have to include in my code? Or is this a bug?

      Thanks for your help.

       

      Greetings,

      Alexander.