Netbeans rocks, especially as it becomes more and more like IntelliJ 😉
The story: NB RCP app, converted to use maven, developed mostly in IntelliJ (with the exception of GUI screens, which go through Matisse).
It’s runnable, it works, but there’s one glitch: debugging only seems to work from inside NetBeans. Should be easy, nbm plugin manual tells what to do here.
Let’s create a Run Configuration, add params, should work, right?
and
And it works! Well, almost, or up to the point where VM complains and quits.
1 2 3 4 5 6 7 8
| [INFO] --- nbm-maven-plugin:3.7:run-platform (default-cli) @ application ---
[INFO] Executing:
/bin/sh -c /Users/ags/vcs/work/trololo-code/client/application/target/trololo_client/bin/trololo_client
--userdir /Users/ags/vcs/work/trololo-code/client/application/target/userdir
-J-Dnetbeans.logger.console=true -J-ea --branding trololo_client
-J-Xdebug -J-Xnoagent -J-Xrunjdwp:transport=dt_socket,suspend=n,server=n,address=8888
[INFO] Invalid memory access of location 0x0 rip=0x7fff958af540
[INFO] ERROR: transport error 202: connect failed: Connection refused |
But it works under NetBeans, and it uses the same parameters and it’s Java and.. WTF?!
What does netbeans exactly do for debugging?
NetBeans: JPDA Listening Start...
JPDA Address: ags-mbpro.local:54019
Port:54019
cd /Users/ags/vcs/work/trololo-code/client/application;
JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
"/Applications/NetBeans/NetBeans 7.2.app/Contents/Resources/NetBeans/java/maven/bin/mvn"
-Djpda.listen=true
"-Dnetbeans.run.params.ide=-J-Xdebug -J-Xrunjdwp:transport=dt_socket,suspend=n,server=n,address=54019"
-Djpda.address=54019 nbm:cluster-app nbm:run-platform
Of course our parameters are correct, running the same command from the command line doesn’t give anything. So the glitch must somewhere else… or. It’s right here, in the very beginning!
NetBeans: JPDA Listening Start...
JPDA Address: ags-mbpro.local:54019
Port:54019
NetBeans starts listening on for debugger BEFORE it runs RCP. Idea can do that too, but by default it wants to connect to a socket. So the easiest way it change it to Listen and start before running the app (meh).
Or change server to y. That’s my preferred way (at least since quite some time).
-J-Xdebug -J-Xnoagent -J-Xrunjdwp:transport=dt_socket,suspend=n,server=y,address=8888