1 Reply Latest reply on Jan 2, 2014 9:55 AM by Jonathan Fuerth

    JSONException in Errai RemoteService REST

    Yernar Adilbekov Newbie

      Hi,tell me please.I used for errai: I have a problem with the current task:


      public class SimpleInterceptor implements RestClientInterceptor {    
             public void aroundInvoke(final RestCallContext context) {    
                  context.proceed(new ResponseCallback() {    
                      public void callback(Response response) {    
                          int statusCode = response.getStatusCode();    
                          if (statusCode == 200) {    
                              GWT.log("it's ok");    
                          if (statusCode == 404) {    
                              GWT.log("Error 404");    
                              // to do something    


      remoteService.call(new RemoteCallback<ServerMessage>() {  
                         public void callback(ServerMessage response) {  
                             Window.alert(response.getText()+" called in HeaderController");  

      public class ServerMessage {
         private String text;
         private Date time;
         public ServerMessage() {
         public ServerMessage(String text, Date time) {
         this.text = text;
         this.time = time;
         getters and setters..

      When I call the service, there is an error: JSONException (JSONParse). What am I doing wrong?

        • 1. Re: JSONException in Errai RemoteService REST
          Jonathan Fuerth Master

          Hi Yernar,


          It's hard to say for sure without seeing the stack trace that comes with the JSONException, but my first guess would be that you forgot to annotate your ServerMessage DTO with @Portable.


          My second guess is that your REST client is getting an HTML error page of some sort instead of the JSON data it was expecting (possibly an Internal Server Error page, or a Not Found page with a status code of 200 rather than 404).


          If you could follow up with the following information, we can probably help you pinpoint the exact issue:


          • The full Dev Mode stack trace associated with the JSONException
          • A dump of the HTTP request that the REST client made, and the response from the server. You can obtain this from the developer tooling in your browser (in Chrome, View -> Developer -> Developer Tools, then click on the Network tab)
          • All log messages generated on the server side while it was processing the REST request