61

I just managed to corrupt contents of my Eclipse .metadata directory. Starting up with eclipse -clean did not work out. Deleting .metadata and then importing all projects, plugins and setting does not sound too interesting. I ended up moving .metadata/.plugins/org.eclipse.core.resources/ elsewhere and reimporting my projects only.

Are there any tools or best practices to recover workspace?

Petteri H
  • 11,779
  • 12
  • 64
  • 94
  • 1
    I've collected some information and useful plugins in my blog post [Restoring a Corrupted Workspace in Eclipse](http://blog.pdark.de/2011/09/02/restoring-a-corrupted-workspace-in-eclipse/) – Aaron Digulla Sep 02 '11 at 12:21
  • Recently using the STS after crashing the IDE changed the location of the workspace to the project's own folder and when trying to open it again it accused a corrupted project. I had to return the workspace location to the correct folder (project's parent folder) and delete the .metadata folder created inside my project folder. – ℛɑƒæĿᴿᴹᴿ Apr 09 '20 at 12:55

15 Answers15

127

When workspace is damaged and Eclipse cannot start, even using the -clean option, removing single file workspace/.metadata/.plugins/org.eclipse.core.resources/.snap may help (source: comments to article https://web.archive.org/web/20200517003712/https://letsgetdugg.com/2009/04/19/recovering-a-corrupt-eclipse-workspace/).

Update: when Eclipse 4.X cannot start after crash, try to start with -clearPersistedState option; if it didn't help then remove file workspace/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi (sources: https://www.eclipse.org/forums/index.php/m/1269045/ https://www.eclipse.org/forums/index.php/t/522428/ https://bugs.eclipse.org/bugs/show_bug.cgi?id=404873). Note: you'll lose configuration of your perspective/views/tabs.

Update: Subversive plugin may be responsible for inability to start Eclipse with corrupted metadata. If you have Subversive plugin installed, update it to latest build (at least 0.7.9.I20120210-1700) from update-site. Related bugs 372621 and 370374 were fixed by Subversive developers.

drac_o
  • 427
  • 5
  • 11
Victor
  • 3,669
  • 3
  • 37
  • 42
25

You should be able to start your workspace after deleting the following file: .metadata.plugins\org.eclipse.e4.workbench\workbench.xmi as shown here :

fastcodejava
  • 39,895
  • 28
  • 133
  • 186
  • 3
    This solved it for me. I didn't have a .snap file as stated by the most upvoted answer. The accepted answer didn't work for me either. – Magnilex Oct 23 '14 at 08:14
  • I don't have .snap as well. Deleting .metadata.plugins\org.eclipse.e4.workbench\workbench.xmi could not solve the problem :/ I can still start other workspaces, but not the corrupted one. – Fluch Apr 16 '19 at 13:59
8

I have some experience at recovering from eclipse when it becomes unstartable for whatever reason, could these blog entries help you?

link (archived)

also search for "cannot start eclipse" (I am a new user, I can only post a single hyperlink, so I have to just ask that you search for the second :( sorry)

perhaps those allow you to recover your workspace as well, I hope it helps.

drac_o
  • 427
  • 5
  • 11
Christopher Thomas
  • 4,424
  • 4
  • 34
  • 49
5

I haven't been able to avoid rebuilding workspace occasionally (one or twice over several years of using eclipse). Delete the .metedata and rebuild.

Ken
  • 2,092
  • 1
  • 19
  • 16
5

One more solution that I've discovered by accident, and may help someone:

  1. Back up the corrupted workspace.
  2. Move half of you projects to some temporary location.
  3. Start Eclipse, if it works, go to step 5.
  4. Move the half of projects you've removed back into the workspace, move out the other half. If you've already done that, keep removing/readding your projects in a binary search manner. Go to step 3.
  5. Exit Eclipse, move back all your projects, and start it again. You should see now that some of your projects are closed (and in the wrong working sets). Re-open your projects and move them to the correct working sets.

In my case, it was a project that got corrupted, and not the entire workspace (attempting to import said project into a fresh workspace caused it to fail as well). So, I've started to search for the faulty project - instead, I got the result described above.

mikołak
  • 9,605
  • 1
  • 48
  • 70
4

This thread may be a bit older, but since this still is a problem nowadays, I thought I’d propose a new solution for backing up Eclipse.

  • At http://profiles.yatta.de you can download the Yatta Eclipse Launcher. You can use it to save your Eclipse and workspace setup.

  • After installation, the Launcher will discover your existing Eclipse installations and workspaces.

  • Click the Upload & Share button (the blue one) on the right of the entry you want to back up.

(You won’t actually “share” your Eclipse or workspace with anyone. You’ll just upload a setup file with your metadata that only you have access to yourself . You could share this later, but you can also just use it as a backup).

If you do that, you’ll be able to re-setup your IDE really fast if you ever have a fragged workspace or Eclipse installation.

L. Hanke
  • 116
  • 1
  • 5
4

I have succesfully recovered my existing workspace from a totally messed up situation (all kinds of core components giving NPE's and ClassCastExceptions and the like) by using this procedure:

  • Open Eclipse
  • Close error dialog
  • Select first project in the workspace
  • Right-click -> Refresh
  • Close error dialog
  • Close Eclipse
  • Close error dialog
  • Repeat for all projects in the workspace
  • (if your projects are in CVS/SVN etc, synchronize them)
  • Clean and rebuild all projects
  • Fixed

This whole procedure took me over half an hour for a big workspace, but it did fix it in the end.

Stijn de Witt
  • 40,192
  • 13
  • 79
  • 80
2

In my case only removing org.eclipse.e4.workbench directory (under .metadata/.plugins) and restarting Eclipse solved the problem.

syntagma
  • 23,346
  • 16
  • 78
  • 134
  • After that I did a file import and it finally loaded all that I had been previously working on in the Project Explorer! Thanks, I had a real mess. – DoesEatOats Aug 21 '18 at 18:35
1

None of the above worked for me. But what actually worked was deleting all *.snap files from my workspace. This also preserves almost all settings including imported projects. Make sure to back up the workspace before trying it though!!!

1

deleting below file helped me solve my eclipse start up issue. Perforce plugin has always troubled me especially when my machine reboots, next time eclipse tries to recover workspace and craps out.

workspace/.metadata/.plugins/org.eclipse.core.resources/.snap

For your reference, Error I was getting: org.eclipse.core.runtime.CoreException: Plug-in com.perforce.team.ui was unable to load class com.perforce.team.ui.UITeamProvider.

Chetan K
  • 31
  • 1
1

In my case, it was not the workspace that was broken, but Eclipse itself, unlike what the error dialog indicated. After reinstalling Eclipse and pointing it to the workspace, the issue was fixed. There might be tools for repairing broken workspaces, but reinstalling Eclipse might be worth a go.

Marko Zajc
  • 307
  • 3
  • 14
  • This sounds more like a comment and not as an answer to this question. Especially the part of you requesting the log file) If I am wrong, please edit your answer to clearly demonstrate how this answers the question and remove the log request. Otherwise, please leave it as a comment once you earn enough reputation. – Yannis Jan 08 '18 at 13:43
  • @Yannis is the answer okay now? – Marko Zajc Jan 08 '18 at 16:54
0

Remove a file with .dat extension in workspace/.metadata/.plugins/org.eclipse.wst.jsdt.core/ and then close eand open eclipse, maybe you cannot close eclipse, force it, with pkill -f eclipse if you are on linux or similar.

This solution avoid to import all of existents projects.

Ferrys
  • 11
  • 1
0

I also experienced an issue like this, my workspace was corrupted and didn't do all the important things anymore.

For some reason, I had a corrupt resource on one of my projects. It didn't show up in the package tree, but it did show in the error log in Eclipse as

Error while creating a link for external folder X:\somefolder

After checking every project (because the error didn't point to one), I indeed found this resource in one of the build paths (in Configure Build Path menu it did show an error icon!) and deleted it.

See Eclipse (Kepler) Workspace acting weird (type hierarchy, searching for references not working) for a wider description of my issue if you're experiencing something similar.

Posted this for future developers to reference.

Community
  • 1
  • 1
bknopper
  • 1,193
  • 12
  • 28
0

I know this sounds obvious, but if I'm writing code for a living I would be sure to do a full backup weekly, with corresponding incremental backups daily.

Simple and easy recovery.

For a simple way to backup your eclipse directory and assuming your using Linux, you could use rsync.

rsync -ar <eclipse-dir> <backup-eclipse-dir>

You can put this in cron and have it backup your files automatically. It will only copy over the changed files to your backup-eclipse-dir on subsequent runs.

RC.
  • 27,409
  • 9
  • 73
  • 93
  • 2
    Thanks, but I'm looking for recovery, not backup, methods. – Petteri H Jun 04 '09 at 22:02
  • 1
    Thanks a lot for this, I do proper backups (with rdiff-backup) but didn't consider getting my workspace back from there for some reason, instead I was looking to recover...fast asleep. – AmanicA Jun 22 '11 at 16:20
-1

If the workspace is not that big you could backup to say dropbox as a private locked folder.

Fred Grott
  • 3,505
  • 1
  • 23
  • 18