views:

95

answers:

2

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?

A: 

I had the same problem lately and unfortunately I haven't found any good solution.

Eventually I created mock implementations of all GWT services I am using in my client side code. When I need to debug client side code I am just switching to these services instead of real services using OSGi underneath. Then in Eclipse I can run GWT application in debug mode. This is far from perfect and requires some work with mocks but it works for me (at least now).

Piotr
Bad news then :(, this is exactly what I was starting to do, but I hoped to find a better solution...
Jaime Soriano
+1  A: 

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:

  • Where do you have your source ($SRC)
  • Where do you have your GWT libraries ($GWT_PATH), specially gwt-user.jar and gwt-dev.jar.
  • (Optionally) the port from wich your HTTP OSGi server serves the application ($PORT).
  • The startUp url of your application ($URL)
  • The package containing the .gwt.xml file for your application ($PACKAGE).

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)
Jaime Soriano
Nice, works perfectly :). The solution isn't that complicated as it seemed at the beginning. However, I have a problem with setting `-port 8080` option in Eclipse. When I set this then it is used only once in the first debug session. When I run debug again this option is erased and GWT debug starts using default `8888` port (all other setting are not erased). This seems to be GWT Eclipse plugin issue. Do you have this problem too?
Piotr
Yes, it was easier than I thought. I started trying to instantiate the DevMode from the Activator but it was a mess. And about the port issue, I had it the first time I modified the arguments, and I thought it was fixed after the second time, but today it has disappeared again :S Anyway I think this parameter is not very important when running in -noserver mode.
Jaime Soriano