Eclipse java debugging: source not found

2019-01-01 02:55发布

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!

29条回答
人间绝色
2楼-- · 2019-01-01 03:27

You might have source code of a dependency accessible to Eclipse. But Eclipse does not know for source code for code that is dynamically loaded. E.g. through Maven.

In case of Maven, I recommend that you use run-jetty-run plugin:

http://code.google.com/p/run-jetty-run/

As a workaround you can also connect to a running JVM with the debugger and you will see the code. Alternatively you can use Dynamic Source Lookup plugin for Eclipse from here:

https://github.com/ifedorenko/com.ifedorenko.m2e.sourcelookup

Unfortunately it didn't helped me as it has issues with Windows paths with spaces.

I have filled an enhancement request on Eclipse Bugzilla and if you agree this issue "Source not found" should vanish forever, please vote for it here:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=384065

Thanks!

Sasa

查看更多
永恒的永恒
3楼-- · 2019-01-01 03:27

If you are on eclipse or STS please install and Use GC(GrepCode Plugin) ,some time you don't need to attach the source .zip file into your project path so GrepCode works fine for you.

查看更多
长期被迫恋爱
4楼-- · 2019-01-01 03:28

Remove the existing Debug Configuration and create a new one. That should resolve the problem.

查看更多
浅入江南
5楼-- · 2019-01-01 03:30

I've had a related issue in connection with Glassfish server debugging in Eclipse. This was brought about by loading the source code from a different repository (changing from SVN to GitHub). In the process, the wrong compiled classes were used by the Glassfish server and hence, the source and run time would be out of sync with break points appearing on empty lines.

To solve this, rename or delete the top folder of the classes directory and Glassfish will recreate the whole class directory tree including updating the class files with the correctly compiled version.

The classes directory is located in: /workspace/glassfish3122eclipsedefaultdomain/eclipseApps/< your Web Application>/WEB-INF/classes

查看更多
有味是清欢
6楼-- · 2019-01-01 03:30

this worked for me

right click on project -> Properties -> Deployment Assembly -> add your jar

查看更多
牵手、夕阳
7楼-- · 2019-01-01 03:31

I was facing the same issue,I followed the bellow steps.

Window => Preferences => Java => Installed JREs,

enter image description here

You see in the above screen Jre1.8.0_12 is selected.

select the JRE you are using and click Edit. Now You should see the bellow screen.

enter image description here

Click on the directory, browse for Jdk, It should look like bellow screen. enter image description here

click ok, and its done

查看更多
登录 后发表回答