javarestgwtjax-rsresty-gwt

Making GWT and REST work together


I have this working code in DevMode however when I run it in compiled code (live), its throwing an error in the Javascript browser console:

Code:

MyService service = GWT.create(MyService.class);
// This works
service.createStuff(title.getText(), content.getText(), new MethodCallback<MyModel>() {
            @Override
            public void onSuccess(Method method, MyModel resp) {
                GWT.log("Response from server: " + resp);

            }
            @Override
            public void onFailure(Method method, Throwable exception) {
                GWT.log(exception.getMessage());
            }
        });
// This does not work
service.readStuff(id, new MethodCallback<MyModel>() {
        @Override
        public void onSuccess(Method method, MyModel model) {

        }
        @Override
        public void onFailure(Method method, Throwable exception) {
        }
    }); 

Error:

com.google.gwt.core.client.JavaScriptException: (TypeError): Cannot call method 'ef' of null
    at Unknown.nn(StackTraceCreator.java:168)
    at Unknown.tl(StackTraceCreator.java:421)
    at Unknown.SU(Exceptions.java:29)
    at Unknown.Hjb(SubmittedPage.java:91)
    at Unknown.qlb(AbstractRequestCallback.java:72)
    at Unknown.Nu(Request.java:287)
    at Unknown.qv(RequestBuilder.java:395)
    at Unknown.anonymous(XMLHttpRequest.java:287)
    at Unknown.Im(Impl.java:168)
    at Unknown.Lm(Impl.java:214)
    at Unknown.anonymous(Impl.java:57) 

How can I at the least debug this kind of issue?


Solution

  • As a start, you can compile to javascript in "pretty" mode which wouldn't produce obfuscated javascript. After that debugging the javascript in the browser is trivial.

    With Mojo's Maven GWT Plugin this is done by the following line:

    mvn gwt:compile -Dstyle=PRETTY
    

    It seems to me however that this is something connected with configuration. Perhaps some kind of injection went bad or was not performed...