Skip to content

Instantly share code, notes, and snippets.

@hpehl
Last active September 19, 2022 12:36
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hpehl/bd00b22586d0c75d37d5fe7f0cfcd823 to your computer and use it in GitHub Desktop.
Save hpehl/bd00b22586d0c75d37d5fe7f0cfcd823 to your computer and use it in GitHub Desktop.
Debug GWT Applications in IntelliJ

Debug GWT Applications in IntelliJ

This is a short introduction about how to use IntelliJ to debug your GWT application running in SuperDevMode.

Prerequisites

Setup

  1. In IntelliJ add a new Run/Debug Configuration of type 'JavaScript Debug'
  2. Give it a name and enter the URL of your GWT application (that's the one you get if you press 'Copy to Clipboard' in the 'GWT Development Mode' window)
  3. Choose Chrome as the browser
  4. Add mapping(s) between your local files and remote URLs. Therefore choose the local path of your (top level) package in the section named 'Remote URLs of local files (optional):' and map it to the related URL of the code server.
    Say you have the local path src/main/java/org/jboss/hal/client and your GWT module has the short name hal. Then the remote URL would be http://127.0.0.1:9876/sourcemaps/hal/org/jboss/hal/client.
  5. If you have a maven multi module (which is the case for me) you can repeat the last step for each module you want to map. In that case you only need to make sure that you don't map the same URL twice. Use more specific mappings in that case.

Debug

  1. Make sure your GWT application is running in SuperDevMode. I'm using the GWT Maven Plugin from Thomas Broyer (https://tbroyer.github.io/gwt-maven-plugin/plugin-info.html) and execute mvn gwt:devmode from the command line. But actually it's up to you how you start SuperDevMode.
  2. Choose your Run/Debug Configuration and click 'Debug' or press ⇧F9
  3. The start page of your GWT application should be loaded in Chrome.
  4. In the browser you should see a hint saying "JetBrains IDE support is debugging this browser."
  5. Depending on your application you should see some output in the console view of IntelliJ.
  6. Add breakpoints in your code. If you setup the mappings correctly, IntelliJ should be activated pausing at your breakpoint. You can now inspect the local variables and walk down the stack.
  7. Have fun

Let me know if you have problems setting up remote debugging.

@kevzlou7979
Copy link

I found out that there is an existing issue https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000715304-Problem-with-Chrome-plugin-and-CORS regarding the CORS - Also on Intelij 2017.3 no need to use Chrome Extension

@kevzlou7979
Copy link

I've tried to update my Intelij IDEA to latest version 2018.2 and you don't need the Chrome extension anymore. And the issue with source had been already fixed.

@vegegoku
Copy link

Seems like the JavaScript debug is only available in Intellij Ultimate.

@ppetr86
Copy link

ppetr86 commented Sep 16, 2022

Just a quick note, this still works fine in Intellij Idea ultimate, the only difference is running gwt with gwt:run instead of the suggested mvn gwt:devmode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment