While debugging a java app in eclipse I receive a "Source not found" error in two cases:
- Stepping in to a file in a different project which is already imported
- Stepping in to a file in an installed maven repository
The files are there, but eclipse won't step into them, instead it shows a button to "attach source"
I tried attaching (which opened a dialog to define a variable?!) and eclipse did jump to the file, but the debugger could not inspect any variables there. Also manually attaching the source for each dependency isn't practical, as in my case there are thousands of dependency files.
I'm new to eclipse\java so an explanation of why this is happening + how to resolve this would help a lot!
Evidently, Eclipse does not automatically know where the source code for the dependent jars are. It is not clear why debugger could not inspect variables once the source was attached. One possibility is incorrect/incompatible source.
Assuming you have a maven project and the sources of the dependencies are downloaded and available in the local repository, you may want to install m2eclipse, the maven eclipse plugin and see if that helps in addressing your issue.
Go to Debug configuration in eclipse and use below goal to run your application.
-Dmaven.surefire.debug
e.g
-Dmaven.surefire.debug exec:java
Eclipse debugging works with the class actually loaded by the program.
The symptoms you describe sounds like the class in question was not found in the project, but in a distribution jar without debug info found before the project you are working with.
This can happen for several reasons but have a look at the location where the classes showing this behaviour is found (look in the navigation pane to identify it). You will most likely need to change the build path of the project to avoid using this jar and have the JVM use the project instead.
EDIT: Note that as of 2018 it is common to use a build framework like Maven, where the build path is managed by the m2e plugin so this problem should be very less frequent than when the question was asked.
I had the very same problem. In my case, I've disabled Window-Preferences-Java-Debug [Suspend execution on uncaught exceptions]. Then, the console showed me the correct error: my MySql user hadn't privileges to access the database. According to this topic.
For beginners,
There is a possibility that the jar file is a part of the project which you have not yet included in the Eclipse workspace.
For that, you need to know the project name of the jar file. Say for example, its abc-18.0.0-SNAPSHOT.jar, it means that the project you are supposed to include in your workspace is abc.