Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Debugging: Source not found

I am having a problem with Eclipse where I can run my program just fine, but when I try to start the debugger, I get this message

Eclipse Window showing error

The picture is a little hard to make out, but instead of getting the normal debugging window, instead it says it is throwing a ClassNotFoundException, and is trying to dislay the source for Launcher$ExtClassLoader.

The thing that really baffles me though is that I can run the code just fine, it is only when I click the debug button that I have the problem.

I have also tried debugging at the command line with JDB, and I got the same error.

So far, I have tried Reinstalling Eclipse and downloading (what I believe to be) the correct Java Development tools for Mac OS X.

I have no idea what else I can try, so any help would be greatly appreciated. Let me know if there is any other information I can provide.

like image 652
Scott Rice Avatar asked Feb 28 '12 01:02

Scott Rice


People also ask

How do I start debugging in Java?

Launching and Debugging a Java program A Java program can be debugged simply by right clicking on the Java editor class file from Package explorer. Select Debug As → Java Application or use the shortcut Alt + Shift + D, J instead.

How do I change the lookup path in eclipse?

Click Edit Source Lookup Path… from Source not found to open the Edit Source Lookup Path dialog. Click Add button from the Edit Source Lookup Path dialog. Select Java Project as the source. Select projects.


2 Answers

Source not found might be legitimate for dynamically loaded code (e.g. Maven).

There are three workarounds known to me (after months of search):

  1. Connect to a running JVM with the debugger and you will see the code.

  2. Use Dynamic Source Lookup plugin for Eclipse from here:

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

  3. Use run-jetty-run Maven plugin

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

I prefer and recommend 3. It works and starts webapp much faster than jetty:run.

Unfortunately 2. 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

like image 91
ssasa Avatar answered Sep 19 '22 13:09

ssasa


Do you have the sources for the files that you are using. If you are using Maven (M2Eclipse) you could download the sources. This might solve the problem. enter image description here

Otherwise you could go and manually attach your sources. Here is how you manually attach sources.

Getting the library paths

Next you have to attach the sources-

Attaching sources

Hope this helps

like image 28
Chan Avatar answered Sep 18 '22 13:09

Chan