Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij IDEA Breakpoints stop in JARs instead of source code of my project

I set a breakpoint in my .java file. I started jetty via maven-jetty plugin. The java file where I set the breakpoint is also packaged into a JAR. Intellij stops at the breakpoint, but it shows me the file which is packaged into the JAR instead of the java file. It behaves as if I set a breakpoint in a java file of 3rd party libraries source code. How can I either make Intellij ignore my JAR or force Intellij to stop at my .java file?

like image 593
gunnar247 Avatar asked Sep 24 '13 21:09

gunnar247


2 Answers

In the current latest version of IntelliJ IDEA (2018.1) there is an option "Show alternative source switcher":

enter image description here

After enabling this option IDEA detects discrepancy of *.java and *.class files and offers to choose source of sources (sorry about tautology). It can ease pain of debugging in projects that consist of many modules.

like image 50
briarheart Avatar answered Sep 27 '22 22:09

briarheart


The setup for this is two fold.

  1. Add the source to one of your modules' classpath. (Project Structure -> Dependencies -> Add -> Module Dependency -> Pick your source and drag it above all library dependencies) enter image description here
  2. Point your Remote Configuration to search for the sources in that particular module's classpath. See picture below Remote Config Sources Search

There is an option to search "whole project" for sources, but this did not set precedence to locally available sources, over downloaded sources, when I attempted to use it. The above solution fixed this problem for me, but it is relatively unsatisfactory when working with a large multiple project setup. i.e I had to pick one particular module's classpath as the source of truth in Remote Configurations. In my opinion, if the local source is present, and "whole project" is the search option, IntelliJ should be smart enough to choose local source over libaries

like image 27
cjbooms Avatar answered Sep 27 '22 21:09

cjbooms