eclipsedebugginggwtosgipax-runner

How to debug a GWT application running on OSGi?


I'm developing a web UI using GWT. While working only with the widgets I could debug from Eclipse using the Firefox extension, but now that I'm integrating the UI with other OSGi bundles I cannot use this solution.

For deploying the GWT application I create the .war and convert it to an OSGi bundle using BND. Then I launch the OSGi container with all the bundles using Pax Runner and Pax Web and the application works correctly, but when something fails in the generated javascript code I don't have any decent output error or debugging facility.

Is there any way to launch the GWT application in "debug mode" from OSGi?

Any other idea that could help in this scenario?

Update: Could it be possible to instantiate com.google.gwt.dev.DevMode or its part with the browser connector from the Activator?


Solution

  • I've finally managed to launch development mode using OSGi, GWT and optionally eclipse. The solution was on the -noserver flag of the GWT dev mode, it's not aware of the changes in code while the application is running, but it can be used for debugging the compiled code and to receive the exception traces.

    I also managed to run the development shell without eclipse, but if you are not interested on this solution you can directly jump to the eclipse integration section.

    Without Eclipse (only exceptions, no debug)

    You need to know the following information:

    Then you need to run:

    java -cp $SRC:$GWT_PATH/gwt-user.jar:$GWT_PATH/gwt-dev.jar \
        com.google.gwt.dev.DevMode -noserver -port $PORT \
        -startupUrl $URL $PACKAGE
    

    E.g.:

    java -cp src/:lib/gwt-2.0.3/gwt-user.jar:lib/gwt-2.0.3/gwt-dev.jar \
        com.google.gwt.dev.DevMode -noserver -port 8080 \
        -startupUrl httplocalgui.html es.warp.samples.httplocalgui
    

    And finally you only need to deploy your application as usual, in my example I do it with pax-runner and pax-web, using the default port 8080.

    With Eclipse

    1. Open the debug configuration for your project
    2. Go to Server tab and uncheck "Run built-in server"
    3. Go to Attributes tab and add "-port 8080" (if 8080 is the port used by your web container). I think that this argument without the built-in server is only used to create the url that the development mode generates to invoke the browser (or that elipse uses to generate an url you can copy and paste in your browser's address bar).
    4. Deploy your application.
    5. Access it from a browser with the GWT extension installed (and don't forget to add ?gwt.codesvr=127.0.0.1:9997)