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.Dev开发者_高级运维Mode
or its part with the browser connector from the Activator
?
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
), speciallygwt-user.jar
andgwt-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
- Open the debug configuration for your project
- Go to Server tab and uncheck "Run built-in server"
- 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). - Deploy your application.
- Access it from a browser with the GWT extension installed (and don't forget to add
?gwt.codesvr=127.0.0.1:9997
)
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).
精彩评论