0

I have a bug (probably a NPE) that occurs in the client part of my GWT app. And it happens only when deployed.

The only message i get is an UmbrellaException in the JS console. No stacktrace, no root cause.

I cannot reproduce the bug locally with the gwt plugin, that would show me the full stacktrace.

So i'm stuck.

Is there any way to :

  • Log the client exception in the server ?
  • Or print a stacktrace in the js console ?

Thanks

EDIT : for future reference : if a bug occurs when deployed and NOT with the gwt runner, it's because the bug concerns the compiled JS. In my case, bad implementation of regexp.

3

2 Answers 2

3

It is possible to use GWT dev mode with a remote server. The launch configuration must include the "-noserver" switch as well as the correct "-startupUrl" (corresponding to the remote server). You can access it from a local browser as usual:

http://my-remote-server/example?gwt.codesvr=127.0.0.1:9997

Note that the HTTP host is the remote server but the "gwt.codesvr" still points to localhost. This means that the application will run server-side code in "my-remote-server" but will use the client code from your local Eclipse, allowing you to debug it. In other words, the "gwt.codesvr" present in the URL tells the GWT browser plugin to compile the code on the fly from localhost instead of using the compiled javascript code present on the remote server. I find this very useful to debug client-side exceptions that I cannot reproduce in my local server.

0

To trap runtime exceptions I resorted to the following:

  1. Introduced a troubleshooting GWT module for my app, e.g. MyAppSnapshot.gwt.xml. In it I am asking the GWT compiler to include stack trace data:

    <?xml version="1.0" encoding="UTF-8"?>
    <module rename-to='client'>
       <inherits name='com.teknoscan.aims.ui.MyAppBase' />
       <set-property name="compiler.stackMode" value="emulated" />
       <set-configuration-property name="compiler.emulatedStack.recordFileNames" value="true" />
    </module>
    

    (There's also a MyAppProduction.gwt.xml with the above properties removed. For more on the meaning of these properties see WebModeExceptions.)

  2. Introduced a pane in my app which is displayed when the GWT.UncaughtExceptionHandler() catches a runtime exception. A helper method parses and sets the text of the stack trace, if available:

      public void setThrowable(Throwable caught) {
      if (!(caught == null || stackTraceTextArea == null)) {
         if (caught.getStackTrace().length == 0) {
            stackTraceTextArea.setText("No stack trace available.");
         } else {
            StringBuffer stb = new StringBuffer();
            stb.append(caught.getMessage() + "\n\nStack trace:\n");
            for (int i = 0; i < caught.getStackTrace().length; i++) {
               stb.append(caught.getStackTrace()[i].toString() + "\n");
            }
            stackTraceTextArea.setText(stb.toString());
         }
      }
    

    (A bit heavy, but in conjunction with the compiler properties gives me a fairly legible Java stack trace information. Certainly not for production builds as the resulting JS is bigger and your users should probably not see stack traces.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.