20
votes

I'm trying to move our Google Web Toolkit (GWT) development from Eclipse to IntelliJ 9 Community edition. So far I've been able to run and debug client/server code successfully via the GWT Maven plugin and its embedded Jetty container.

However, I'm having trouble debugging client code when it is already running on a remote machine (and hence there's no need for the embedded Jetty container).

Has anyone been successful at achieving this? Any help would be appreciated!

UPDATE: I was finally able to accomplish this. Please see my own answer below...

2
What do you mean by "having trouble"? AFAIR, on Google I/O 2009 there was a presentation showing debugging a GWT app that was running on a VM (the debugging was done from the host machine). It seems perfectly doable (by default the browser plugin connects to 127.0.0.1) - remember to add an appropriate IP to the white list of the OOPHM Firefox plugin. - Igor Klimer
@Nadav: Is IntelliJ IDEA's community edition any good for GWT development? For "Java Web development" (like, say, JSPs and Servlet) the community edition sure **** big times :( - SyntaxT3rr0r
@WizardOfOdds: I guess it depends on what you define as good :) If you don't mind having to manually add the run/debug configurations by hand then it's an awesome editor for GWT. Basically since it can do Java and Maven very well, GWT fits nearly perfectly. Besides what I already mentioned, the only stuff that is missing is CSS support (or JSP for that matter) - if you ask me, it already is a ton better than Eclipse. - Nadav
@Igor: I'm not sure whether the demo in that video was from an embedded container or from a separate (remote) one, but I was referring to the latter. In any case, you're correct, and it turns out that it is doable with the -noserver flag with the DevMode runner. - Nadav

2 Answers

22
votes

I was finally able to accomplish this by using GWT's DevMode class, as described in the documentation.

In short -

  • Add your project to IntelliJ 9 Community edition
  • Add an Application run/debug configuration
  • Use com.google.gwt.dev.DevMode as your main class (make sure to include gwt-user and gwt-dev jars to the project classpath. See here)
  • Add the following program parameters:

    -noserver -war "[full path to your exploded war]" -gen "[full path to generated files]" -logLevel INFO -port [remote server port] -startupUrl "[URL of the remote page]" [com.company.YourEntryPoint]

This way, the DevMode runner will not instantiate the built in container and will allow your remote server's JavaScript to be debugged in its original Java form.

Note that for builds that don't require debugging remote client code you may use Maven or Ant integration, which is much simpler. I don't have any experience with the webAppCreator generated build.xml, but with Maven you could simply run the gwt:run or gwt:debug goals with this parameter: -DrunTarget=

Hope it helps!

1
votes

When running a GWT app deployed on a remote server, the client part of your app will have been translated into javascript so I do not think you will be able to debug this from IntelliJ. The server side part of your app will still be Java code. You should be able to start up this remote server with java debugging parameters (things like a transporttype and a port to listen to). From IntelliJ, you should be able to start up a remote debugging session using the same transporttype and port. If you look into remote debugging, you should be able to find how to do this.