Wednesday, October 21, 2009

Repairing a corrupt eclipse workspace

I've had Eclipse crash on me many times in the past and left things in a state where I couldn't get the workspace to start back up properly. Eclipse would lock-up when restarting. I have always fixed it by simply creating a new workspace and then rechecking out my projects from SVN. But that is a tedious process, and can be a real hassle.

So this time I decided to find a better way. Victor Igumnov provided the solution in his blog. Thanks Victor!

This solved my problem for the most part, however, if you are using a multi-module maven project with eclipse and the m2eclipse plugin, a simple project import didn't get things set back up as they were.

Before eclipse crashed, I had checked out a maven project with subversive using the "Check out as Maven project" feature. When you do this, root-level eclipse projects are created for all maven modules and submodules that are being checked out.

After the crash, doing an "Import -> Existing projects into Workspace" would only create a root-level eclipse project for the parent maven project. Instead, to get back root-level eclipse projects for all maven submodules, you need to do an "Import -> Maven Projects".

After doing that, my workspace was back up and running as it had been before.

---

UPDATE: 2/4/2010

An alternative method that I discovered might work as well, but I still ran into some problems and had to resort to the method above. If it had worked, it would have enabled me to get back up and running even faster. I had problems even with the first method, so I'll try this method again next time this problem happens and see if I have any better luck.

A MyEclipse forum posting gave me the clue for this alternative method. Simply rename a directory called .projects and restart eclipe. Then, once it has started, shut it down, delete the newly created .projects folder and rename the original back to .projects. When Eclipse is started up again, everything seems to work properly. The .projects directory is located at:
%WORKSPACE%/.metadata/.plugins/org.eclipse.core.resources/.projects

When I tried this, Eclipse started up without problems. However, one of my projects was missing its pom.xml, which made it so that none of the source folders were showing up. All I did was right-click on the project and do a "Refresh" (or F5). It then attempted to rebuild the project. Unfortunately, it would finish the build and seemed to keep repeating going from 67% to 70% and then back again.

In the end, I restarted Eclipse, but then it froze on me again during startup. So I resorted to the first solution at the top of this posting. But even after doing it, the build would repeat over and over again. Eclipse had crashed when I was doing some refactoring, and my code was in an invalid state. Once I corrected it, then the build completed properly. So it is possible that this alternative method would have worked after all.


2 comments:

muriloq said...

Thanks for your post. I had the same problem (with Spring Tools Suite) and your suggestion fixed it.

Unknown said...

Thanks its working now... u are a star

 

Labels

Labels