1

I have a Java project in Eclipse with several classes and a bunch of debug configs to test them. Up until today debugging was working fine. I just tried debugging one of the configs and got Error: Could not find or load main class. Same problem with the other configs. I also have an ant build.xml file that I run that exports a JAR. This JAR ran fine outside Eclipse with the class I wanted to debug. Read up on this here and here and tried a few things that were suggested there but none helped. Cleaned the project; checked that "java builder" is picked under project builders; checked .classpath. Nothing suspicious.

Trying to remember what happened between the last time I debugged and now. One thing stands out: out sysadmin rebooted my (RedHat) machine while I was working in Eclipse (thanks dude!). I did not see any error messages when I restarted Eclipse but could this have messed things up that can't be fixed by simply cleaning the project?

Whether or not that was the reason, what else can I check/try to get this to work again?

UPDATE: I found a way to get this to (sort of) work, but it feels more like a workaround rather than a solution since I still don't know what the problem is. What I did was I:

  • Made a copy of my project dir (cp -r Proj Proj2)
  • Deleted everything from Proj2 except for src/, lib/ and build.xml
  • Created a new Java project in eclipse and pointed it to Proj2
  • Also modified Proj2/build.xml to refer to Proj2 instead of Proj -- this isn't really relevant to the original issue, but I am listing it for completeness

The result is that debugs work in Proj2, but they still don't in the original Proj

Community
  • 1
  • 1
I Z
  • 5,719
  • 19
  • 53
  • 100
  • Try right-clicking on your server (in your servers window) and cleaning that, too, and the server's work directory (webapps directory). This sometimes works when nothing else does. – whistling_marmot Jan 26 '16 at 22:04
  • Try ./eclipse -clean -clearPersistedState – Mohit Sharma Jan 26 '16 at 22:11
  • Try disabling your anti-virus. Worked for me when the debugger just randomly wouldn't load. – z7r1k3 Jan 26 '16 at 22:13
  • If it is standard Java project in Eclipse, the classes are in bin folder, can you check, that you class is there ? I had o problem, that Eclipse was not able to delete the content of the folder and while failing on delete it was not compiling the code and so on... – Betlista Jan 27 '16 at 08:13
  • @whistling_marmot Got `Could not create the view: org.eclipse.wst.server.ui.ServersView` when I tried `Window->Show View->Other->Server->Servers` – I Z Jan 27 '16 at 13:16
  • @MohitSharma Started eclipse with that command, tried debugging, same result – I Z Jan 27 '16 at 13:19
  • @Betlista Hmm, weird. The `bin` dir seems to be unused: most `class` files are missing, the others are ancient, much older than when I was successfully debugging. Are my project settings out of whack? – I Z Jan 27 '16 at 13:27
  • Maybe you've lost your old server somehow, and you need to add a new server (Tomcat, Jetty, etc.). On a few occasions, I've ended up installing a new version of eclipse and pointing it to my existing workspace. Do your other projects still work? – whistling_marmot Jan 27 '16 at 21:27

1 Answers1

0

The answer based on my comment.

Check, whether bin is set as output folder:

Eclipse Java project > Java Build Path > source tab

if so and it seems "unused" - it might be, that Eclipse have some problem cleaning it - do the clean manually and try clean and rebuild (if you have "build automatically" set, just perform clean from eclipse) and check, that the classes are in bin...

Eclipse: Project > Clean...

Betlista
  • 10,327
  • 13
  • 69
  • 110
  • by "do the clean manually" do you mean deleting all files and subdirs of `bin/`? – I Z Jan 27 '16 at 16:25
  • exited eclipse, deleted contents of `bin/`, started eclipse, cleaned project, checked that "build automatically" is on, also ran ant build. Then tried to debug: same result – I Z Jan 27 '16 at 17:51
  • @IZ Yes, by "do the clean manually" I meant delete on file system. After build, is content of your bin correct - as expected ? – Betlista Jan 27 '16 at 18:13
  • I moved the existing `.log`, then restarted eclipse. There was a small number of messages including a couple that looked like errors/warnings. One was `!MESSAGE Keybinding conflicts occurred. They may interfere with normal accelerator operation.`, the other was `!MESSAGE A conflict occurred for ALT+CTRL+U:...` Neither looks relevant – I Z Jan 27 '16 at 22:13
  • Those are not relevant. Can you please answeralso whether there are classes in bin after rebuild ? – Betlista Jan 28 '16 at 07:27
  • No, the `bin` folder is empty – I Z Jan 28 '16 at 12:22
  • Ok, but you have this one set as output folder, right? Do you have projects, your depends on? Try to close other project and rebuild manually = try to turn off-on automatic build and so on... – Betlista Jan 28 '16 at 20:39