8 Replies Latest reply on Apr 17, 2011 11:00 AM by Luca Iachini

    JSONException

    Luca Iachini Newbie

      Hi,

      When I receive a message on the client sometimes I have a JSON Exception.

       

      JSONUtilCli.decodePayload=[{"ToSubject":"SpirareReciver","Etichetta":"A02","Lato":"DESTRO","Movimento":false]
      com.google.gwt.json.client.JSONException: Error parsing JSON: SyntaxError: missing } after property list
      at com.google.gwt.json.client.JSONParser.throwJSONException(JSONParser.java:91)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:616)
      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:157)
      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:126)
      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.parseLenient(JSONParser.java:70)
      at com.google.gwt.json.client.JSONParser.parse(JSONParser.java:54)
      at org.jboss.errai.bus.client.json.JSONUtilCli.decodePayload(JSONUtilCli.java:49)
      at org.jboss.errai.bus.client.framework.ClientMessageBusImpl.procIncomingPayload(ClientMessageBusImpl.java:1115)
      at org.jboss.errai.bus.client.framework.ClientMessageBusImpl.access$7(ClientMessageBusImpl.java:1113)
      at org.jboss.errai.bus.client.framework.ClientMessageBusImpl$LongPollRequestCallback.onResponseReceived(ClientMessageBusImpl.java:877)
      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.GeneratedMethodAccessor40.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:616)
      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:157)
      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:126)
      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.GeneratedMethodAccessor25.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:616)
      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:157)
      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(Thread.java:636)
      

      Any way to avoid that?

        • 1. JSONException
          Mike Brock Master

          What version is this?

          • 2. Re: JSONException
            Luca Iachini Newbie

            Hi Christopher,

            For versions of this below I put the piece of pom.xml file. I followed the guide http://community.jboss.org/wiki/WorkingwithGWTCDIandErrai  to setting up the project.

             


                <properties>
                    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                    <errai.version>1.2.2.Final</errai.version>
                    <errai-jms.version>1.1-SNAPSHOT</errai-jms.version>
                    <gwt.version>2.1.1</gwt.version>
                    <hsqldb.version>1.8.0.7</hsqldb.version>
                    <weld.version>1.1.0.Final</weld.version>
                    <gwt.maven>2.1.0</gwt.maven>
                    <mvel.version>2.0.18-RC4</mvel.version>
                    <jetty.version>6.1.25</jetty.version>
                    <slf4j.version>1.5.11</slf4j.version>
                    <uel.impl.version>2.1.2-b04</uel.impl.version>
                    <webDescriptor>jetty</webDescriptor>
                </properties>
            
            • 3. Re: JSONException
              Mike Brock Master

              The only way I can think of this can happen is if the message is uncommitted before it transmits.

               

              Is there a consistently re-producable set of code you can submit to us so we can test it?

              • 4. Re: JSONException
                Luca Iachini Newbie

                the application is very large and many messages are sent. I have this error many times when brodcast messages are sent from the server .

                There may be problems if the messages are sent in parallel?

                I can show you some pieces of code.

                 

                 

                Server(This is a event):


                @Override
                public void inizioMovimentoNastro(NastroEvent e) {
                MessageBuilder.createMessage().toSubject("NatroReciver").signalling()
                .with("Lato", e.getLato().name()).with("Movimento", true)
                .done().sendNowWith(bus);
                
                }
                

                 

                Client:

                 

                bus.subscribe("NatroReciver", new MessageCallback() {
                
                @Override
                public void callback(Message message) {
                String lato = message.get(String.class, "Lato");
                boolean movimento = message.get(Boolean.class, "Movimento");
                if (lato.equals(getLato()))
                if (movimento){
                lNastro.setBackgroundColor("#1C7FE3");
                }
                else{
                lNastro.setBackgroundColor("#000000");
                }
                
                }
                }); 13/04/2011 11:27:32
                
                • 5. Re: JSONException
                  Luca Iachini Newbie

                  I also tried this but still got the same error:

                   

                  Server:

                  @Override
                      public void inizioMovimentoNastro(NastroEvent e) {
                          MessageBuilder.createMessage().toSubject("NatroReciver")
                                  .with("Lato", e.getLato().name()).with("Movimento", true)
                                  .noErrorHandling().sendGlobalWith(bus);
                  
                      }
                  
                  
                  

                   

                   

                  Client:

                   

                  bus.subscribe("NatroReciver", new MessageCallback() {
                  
                              @Override
                              public void callback(Message message) {
                                  String lato = message.get(String.class, "Lato");
                                  boolean movimento = message.get(Boolean.class, "Movimento");
                                  if (lato.equals(getLato()))
                                      if (movimento){
                                          lNastro.setBackgroundColor("#1C7FE3");
                                      }
                                      else{
                                          lNastro.setBackgroundColor("#000000");
                                      }
                  
                              }
                          });
                  
                  • 6. JSONException
                    Luca Iachini Newbie

                    When there are two or more clients connected I get this error in one of them.

                    • 7. JSONException
                      Mike Brock Master

                      Can you try with Errai 1.2.3-SNAPSHOT and tell me if you still experience the problem?

                      • 8. JSONException
                        Luca Iachini Newbie

                        With version 1.2.3-SNAPSHOT the application works. Thank you so much Christopher.