Justin
Justin

Reputation: 86789

I get "Source not found" when debugging my Java code in Eclipse

I'm trying to debug my Java application in Eclipse however when I hit a breakpoint I simply see the following instead of my source:

Source not found message

If I change the stack frame in the Debug window then I can see the function name change in the tab - this is definitely my code, the line number is correct and I'm using the latest build but I still can't get Eclipse to show the source (despite it being open in another tab!)

I'm new to Eclipse and so I'm struggling to find my way around, but everything that I've stumbled across so far seems fine to me.

What might cause this to happen and how can I fix it?

Upvotes: 37

Views: 95310

Answers (17)

anonymous guest
anonymous guest

Reputation: 11

I was facing same issue. After banging my head for several hours, I finally noticed that although Maven was building the project successfully, the source file I was trying to step into had an incorrect package statement and that is why the 'Source Not Found' eclipse problem was happening. When I corrected the package statement and rebuilt the project, the debugger found source file and stopped on my breakpoint.

Upvotes: 1

Asanka Siriwardena
Asanka Siriwardena

Reputation: 991

This occurred to me when my working git branch is updated from code in master branch. I have already run mvn clean install after the pull, but seems I had to update projects after the maven build so that project source code and JAR build code gets synchronized.

Right click on your project -> Maven -> Update Project, then select all the maven modules available and press OK. This resolved the issue for me.

enter image description here

Upvotes: 0

Aravind
Aravind

Reputation: 1

In Eclipse:Window-->Go to preferences-->Java-->Click on JRE-->Edit--->Restore Default and click on Finish.

Update your Project before Debugging the code!

Alas! It worked for me.

Upvotes: 0

Kabiraj Kharel
Kabiraj Kharel

Reputation: 205

I also had this issue in MyEclipse Blue. I resolved it by following these steps:

  1. Debug the project.

  2. Right click on the Thread (Which you will see in Debug tab) and click on the "Edit Source lookup"

  3. New window will open and hit the "Add" button and Select the "Java Project".

  4. Get all the project that is listed over there.

  5. Restart your server.

Upvotes: 9

ericksjo
ericksjo

Reputation: 11

This is an expansion on JAB's answer: Click "Edit Source Lookup..." > Add... > Workspace Folder > Project > select your folder > check Search subfolders box > OK.

Upvotes: 0

eddieB
eddieB

Reputation: 43

In your debug configuration add goals as "clean install"in the maven build con

Upvotes: 0

Shobhit Mittal
Shobhit Mittal

Reputation: 21

After trying most of the solutions here, try this too once -

Close all the .java files from the editor, in fact, close all unrelated projects in eclipse. And try running the Debugger.

Upvotes: 1

jovanchohan
jovanchohan

Reputation: 153

I got this error when I was running my server using a maven tomcat plugin. When I deployed using my configured server in Eclipse (generating a war file and copying it into my tomcat directory), I didn't have this issue anymore.

Upvotes: 0

Bug
Bug

Reputation: 483

This is a common error while debug in eclipse. You can fix it through edit source look up. But make sure once you attach the Project You need to stop the server and again start in Debug mode. It will work.

Here is the detail steps :

Click on "Edit Source Lookup Path" button . Then click on Add button. Select Java Project and include your imported project Then stop the server and start it in Debug mode and hit your service. It will work.

Upvotes: 1

user4772709
user4772709

Reputation:

Try this:

  • Select Project
  • Right click
  • debug
  • Debug configuration
  • Select Source Tab
  • Click on add button
  • Select Java Project
  • Add your project there with check box

Upvotes: 3

nandox
nandox

Reputation: 55

When I faced this problem for the very first time, I've already done all the steps mentioned here. Curiously, my problem happened when I've copied a project into another place. Anyway, the debug starts to work without warnings, after simply remove all breakpoints that was originated from the original project. Sorry about my English , I'm not fluent.

Upvotes: 3

krzysiek.ste
krzysiek.ste

Reputation: 2276

I had similar problem with my eclipse maven project. I fought with this issue quite a long time then I tried to rebuild projet with

mvn clean eclipse:eclipse

and it helped.

Upvotes: 4

tony.wang
tony.wang

Reputation: 13

I solved this problem by adding the class file into the src folder within the project. Hope this method may help.

Upvotes: 0

Filip Spiridonov
Filip Spiridonov

Reputation: 36250

For local projects I've solved it by selecting the "Resolve Workspace artifacts" checkbox in the Debug Configurations.

Upvotes: 1

Jeroen
Jeroen

Reputation: 21

We had the same problem and none of the suggestions above worked. What did work, was deleting the local workspace and from Eclipse checking out from the repository again. The problem occured for everybody previously working with Netbeans and making the switch to Eclipse.

Upvotes: 2

JAB
JAB

Reputation: 3616

Click on "Edit Source Lookup Path" button and then click on Add button then Java Project and include your imported project .. Hope this will solve your problem

Upvotes: 15

rich
rich

Reputation: 19424

Sounds like the 'source lookup path' section if you edit the debug configuration isn't setup correctly?

Upvotes: 24

Related Questions