Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

eclipse debugger: attaching source-code of maven dependencies?

I'd like to use the source code of maven-managed dependencies when debugging our webapp in myEclipse 8.

I have managed to attach the sources to the libraries in the "Maven Managed Dependencies" classpath container, i.e. when I open a class file from a dependency (e.g. using Ctrl-Shift-T), I see the source code.

However, when I define a server connector for my tomcat, deploy the wepapp to it, and launch it in debug mode and execution halts on a breakpoint in that same class, the editor pane only displays the text "source not found", and a button to edit the "source lookup path". I have attempted to manually add the "Maven Managed Dependencies" classpath container, only to be told "Use maven project settings to configure depedency resolution". However, I see no useful setting in that property pane ...

How can I attach those sources? I am aware that this works with the m2e plugin and wtp, but I'd rather avoid convincing the rest of my team to switch plugins ...

like image 279
meriton Avatar asked Nov 27 '09 13:11

meriton


People also ask

Where do I put Maven dependencies in Eclipse?

Via the Maven index, you can search for dependencies, select them and add them to your pom file. To download the index, select Windows > Preferences > Maven and enable the Download repository index updates on startup option. After changing this setting, restart Eclipse. This triggers the download of the Maven index.

How do I fix missing Maven dependencies in Eclipse?

Right-click on the project and choose Properties, and then Maven. Uncheck the box labeled "Resolve dependencies from Workspace projects" Hit Apply, and then OK. Right-click again on your project and do a Maven->Update Snapshots (or Update Dependencies)


2 Answers

Looks like issue MNGECLIPSE-983

I have confirmed that if I manually pick the External Archive option and find the relevant -sources jar (navigating that big .m2/repository tree to find it) and then add the jar as a sources it does work, and surprisingly it does remember the next time which isn't too bad.
That's at least doable I think for me because we don't often need to step debug through external dependencies, but when we do, it's often frequent, so adding it once while a bit of a pain, can be done on a case by case basis.

like image 129
VonC Avatar answered Sep 21 '22 18:09

VonC


I have since discovered that this problem only occurs if the server is launched using a launch configuration.

The problem does not occur if the server is started by:

  1. click the server icon in the toolbar -> context menu appears
  2. mouse over the intended server -> submenu appears
  3. click on "Start"

While this precludes sharing the server configuration by checking the launch configuration into version control, it at least allows seamless debugging.

like image 20
meriton Avatar answered Sep 22 '22 18:09

meriton