IntelliJ steps through the wrong lines when debugging remote Java application

Faur Ioan-Aurel picture Faur Ioan-Aurel · Oct 10, 2012 · Viewed 8.3k times · Source

I tried to remote debug a maven plugin for liquibase project with Intellij. The problem is that IDEA is highlighting the wrong source code line and I can't figure why. The source code that I try to debug is untouched. I manualy build and installed the plugin in my local maven repository from the sources the I use in Intellij. My Intellij version is 11.1.3 and maven version is 3.0.4 running on Ubuntu 12.04.

For debugging the maven plugin I used mvnDebug comand. If someone have the slightest idea about what is wrong than please give me some advices. Also if you need some more information please ask. I'm not too used to remote debugging (in fact this is the second time I done this) so I might slipped some information that you need.

Answer

noahlz picture noahlz · Oct 10, 2012

For me, whenever IntelliJ is highlighting the wrong line, it was always because the version of the JAR/classes being used to run the application differs from my source files - i.e. different version of the sources were used to build the JAR and/or classes.

You are going to have to be sure that you are working from the exact source that was used to build the classes you are debugging.

You can verify this by looking at the classpath being used to launch the application, locating the JAR file or classes directory that contains the classes you are debugging, and verifying that they were built from the sources you are inspecting.

Note that when you are debugging third-party libraries, you often can download the "sources" jar (see IntelliJ2-IDEA get Maven-2 to download source and documentation).