5 Replies Latest reply: Jan 2, 2012 2:42 PM by Craig Greenhalgh RSS

    JSONException in RPC part 2

    Pol Patric Newbie

      Hello,

      When I receive a message on the client I have a Exception:

       

      [ERROR] com.google.gwt.json.client.JSONException: Error parsing JSON: SyntaxError: JSON.parse: bad control character in string literal
      [ERROR]         at com.google.gwt.json.client.JSONParser.throwJSONException(JSONParser.java:91)
      [ERROR]         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [ERROR]         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      [ERROR]         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      [ERROR]         at java.lang.reflect.Method.invoke(Method.java:597)
      [ERROR]         at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
      [ERROR]         at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
      [ERROR]         at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167)
      [ERROR]         at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:326)
      [ERROR]         at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:207)
      [ERROR]         at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:132)
      [ERROR]         at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
      [ERROR]         at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
      [ERROR]         at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
      [ERROR]         at com.google.gwt.json.client.JSONParser.evaluate(JSONParser.java)
      [ERROR]         at com.google.gwt.json.client.JSONParser.parse(JSONParser.java:218)
      [ERROR]         at com.google.gwt.json.client.JSONParser.parseStrict(JSONParser.java:87)
      [ERROR]         at org.jboss.errai.bus.client.json.JSONUtilCli.decodePayload(JSONUtilCli.java:48)
      [ERROR]         at org.jboss.errai.bus.client.framework.ClientMessageBusImpl.procIncomingPayload(ClientMessageBusImpl.java:1158)
      [ERROR]         at org.jboss.errai.bus.client.framework.ClientMessageBusImpl.access$7(ClientMessageBusImpl.java:1156)
      [ERROR]         at org.jboss.errai.bus.client.framework.ClientMessageBusImpl$LongPollRequestCallback.onResponseReceived(ClientMessageBusImpl.java:993)
      [ERROR]         at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
      [ERROR]         at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)
      [ERROR]         at sun.reflect.GeneratedMethodAccessor26.invoke(Unknown Source)
      [ERROR]         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      [ERROR]         at java.lang.reflect.Method.invoke(Method.java:597)
      [ERROR]         at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
      [ERROR]         at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
      [ERROR]         at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167)
      [ERROR]         at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:326)
      [ERROR]         at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:207)
      [ERROR]         at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:132)
      [ERROR]         at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
      [ERROR]         at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
      [ERROR]         at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
      [ERROR]         at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
      [ERROR]         at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:214)
      [ERROR]         at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source)
      [ERROR]         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      [ERROR]         at java.lang.reflect.Method.invoke(Method.java:597)
      [ERROR]         at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
      [ERROR]         at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
      [ERROR]         at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167)
      [ERROR]         at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:281)
      [ERROR]         at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:531)
      [ERROR]         at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)
      [ERROR]         at java.lang.Thread.run(Thread.java:662)
      

       

      this is my code on Server side:

       

      public String getPing(String result) {
            String line = null;
              try {
                    Process p = Runtime.getRuntime().exec("ping -n 1 " + result);
                    BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
                    while ((line = input.readLine()) != null) {
                        //System.out.println(line);
                        result = line + "\n";
                    }
                    input.close();
      
              } catch (Exception err) {
                    err.printStackTrace();
                    return "ErrorPwList";
                }
              return result;
          }
      

       

      and Client:

       

              sendButton3.addClickHandler(new ClickHandler() {
                  public void onClick(ClickEvent clickEvent) {
                      MessageBuilder.createCall(new RemoteCallback<String>() {
                          public void callback(String response) {
      
                              // Run popup dialog box
                              sendButton3.setEnabled(false);
                              dialogBox.setText("RPC - Success");
                              dialogBox.center();
                              //window.centerInPage();
                              closeButton.setFocus(true);
      
                              textToServerLabel.setText(response);
                          }
                      }, RPCTestService.class).getPing(nameField3.getText());
                  }
              });
      

       

      Is this a bug?

      Thanks for your help.

       

      Greetings,

      Patric