I am using Eclipse 3.4.2 with the latest GWT. The IDE doesn't even switch to Debug Perspective automatically.
10 Answers
Do you launch your GWT application in hosted mode ?
You will spend most of your development time running your application in hosted mode, which means that you are interacting with your GWT application without it having been translated into JavaScript.
Anytime you edit, run, and debug applications from a Java integrated development environment (IDE), you are working in hosted mode.
When an application is running in hosted mode, the Java Virtual Machine (JVM) is actually executing the application code as compiled Java bytecode, using GWT plumbing to automate an embedded browser window.
This means that the debugging facilities of your IDE are available to debug both your client-side GWT code and any server-side Java code as well.
Tip: If you are using Eclipse, you can also create a launch configuration file when creating a new project with
applicationCreator
by using the -eclipse flag.If you didn't use
applicationCreator
to create an application-specific hosted mode shell script, you can manually run the main class incom.google.gwt.dev.GWTShell
found (depending on your OS) ingwt-dev-windows.jar
,gwt-dev-linux.jar
, orgwt-dev-mac.jar
.Important: If you are not using the generated
<module>-shell
script, be aware that in hosted mode, the GWT development shell looks for modules (and therefore client-side source) using the JVM's classpath. Make sure to add your source directories first in your classpath.
See also Debug in Hosted Mode
(source: googlecode.com)
These days, it seems that GWT classic dev mode is no longer supported, or at least not recommended. It's been replaced by GWT super dev mode, which runs your code in Javascript, not on the JVM. This means that you debug in your browser, instead of in Eclipse. For example, I visited my site in Chrome, opened the developer tools, switched to the sources tab, and then looked under the sourcemaps folder to find all my Java classes. I can put breakpoints there, and the browser will stop when the Javascript equivalent is running. I can inspect the Javascript variables that roughly match my Java variables.
If you really prefer debugging in Eclipse, you can use the Super Dev Mode Debugger Eclipse plugin, but it's doing the same thing as the Chrome debugger. When I tried it out, I had to watch the video to get it working.
I'm running 1.6.0_13 and still the debug doesn't work. It just doesn't hit the breakpoints. And more, the page shows up blank in hosted mode (except for the static content in the HTML file), but everything displays and works correctly when running on the browser.
java -version
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
I was also following the StockWatcher guide on the GWT website and then got to the Debugging part of the tutorial and I could not get my breakpoints to trigger until I stumbled upon the SDBG plugin. I installed the plugin and followed the video and it worked!
My environment:
- Eclipse Neon.1a Release (4.6.1)
- JDK 1.7.0_80
- GWT SDK 2.7.0
Additional Notes:
Make sure to make a Debug Configuration and use com.google.gwt.dev.DevMode
as your Main class.