Is there anything to prevent re-importing all projects when Eclipse crashes? - eclipse

Eclipse has bugs. It crashes, it freezes. And even if it doesn't the underlying OS might have its problems too. It is a fact of life.
The problem is that every time the Eclipse was brutally terminated, I am forced to delete the .metadata/.plugins/org.eclipse.core.resources folder, otherwise Eclipse wouldn't load the workspace at all.
But when I do this, the Eclipse forgets about projects in project explorer. Re-importing it again is not that much hassle, but it gets more and more annoying the more projects I work on and the more frequently the Eclipse needs to be terminated.
Is there any way to prevent the need to re-import all projects? Firefox for example, when terminated brutally, doesn't need to loose the information about the current session, because there are addons (e.g. Session Manager) that can revive old working session.
Or maybe there is a way to automatically repair the broken data in .metadata/.plugins/org.eclipse.core.resources? (It might not be that easy, since all files are binary).
Or maybe there is a way to automate workspace importing? Running such a script will be a huge time-saver.

Things I would try in order:
Start eclipse with -clean flag: ./eclipse -clean
Delete the .lock file: workspace/.metadata/.lock
Inspect the log files: workspace/.metadata/.log
Delete the .snap file workspace/.metadata/.plugins/org.eclipse.core.resources/.snap
If you are using eclipse4, delete workbench file: workspace/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi
Delete the project .markers.snap files workspace/.metadata/.plugins/org.eclipse.core.resources/.projects/*/.markers.snap
Edit: .snap file can be named .snap or .markers.snap depending on your eclipse version

Related

Why does my Eclipse takes so much times to clean files?

I'm using Eclipse Kepler on Windows 7 and recently it became more and more frequent that it takes lots of time when it has to delete files. For example in these contexts:
mvn clean launched from Eclipse
cleaning output folder in case of automatic projects build by Eclipse
deploying a war on a server (deletion of the previous deployment)
I've checked this old question but working in a fresh new workspace has no effect.
I may have a clue: to gain some time I 'help' Eclipse by deleting the files myself with Windows Explorer. Windows often launches a pop-up saying that I need admin right to do that. I just hit Enter (I am admin user) and the files are quickly deleted. If Eclipse had no right to delete the files I would have expected an error, instead it just takes much more time to actually delete the files.
Why could be the cause of that? Knowing that the clue may or may not be relevant.
For the record: no solution has been found to the problem. I got a new desktop with a fresh Win7 image and I don't have the problem, working with the same Eclipse projects.
This would indicate that the problem came from a misconfiguration of the Windows user permission. Sadly, no more details available.

Eclipse - “Workspace in use or cannot be created, chose a different one.” even after I removed .lock

I moved my workspace, moved it back, and now I get this error. The other thread on this error suggests I delete the .lock file from the .metadata folder, but it doesn't work.
Sometimes the eclipse or java process is still running, even if you don't see any UI of Eclipse anymore. It might then still hold file locks or other OS specific resource locks.
Therefore please always kill all eclipse processes (and the related java processes) before trying to use a workspace again after a crash. If you are unsure about the processes, rebooting is the safe way to do this.
You can try to launch Eclipse as Administrator. Probably you have a permissions problem
in your commandline, run eclipse as:
eclipse -clean

Eclipse IDE does not start

My computer suddenly shut down due to power failure, while I was working on an Android project using my Eclipse Indigo IDE.
Now, if I start Eclipse, only an empty message dialog (see screen shot) appears and Eclipse does not start. What can I do?
(I am using Ubuntu 12.04 LTS)
Mabe Some files found in the .metadata folder of your workspace are damaged, have you tried to launch it by specifying another workspace?
You can manually specify the workspace location on the command line, using the -data command-line argument.
If you don't want to loose a lot of time by trying to fix the problem, you can import your projects into the new workspace, reinstall the plugins that was installed before and everything will be ok. otherwise, you have to take a look on the .log file found in the .metadata folder of your old workspace, analyse the stacktrace and try to understand which plugin is corrupted and delete it manually, and this may take a lot of time, thats why i suggest you the first solution. About the .metadata folder, it is in ~old_workspace/.metadata.
check your filesystems. Maybe something got corrupted when power was lost.
Check my blog post When Eclipse Won't Start and Restoring a Corrupted Workspace in Eclipse
For me, .metadata files were damaged. Since eclipse was not opening at all, changing the workspace was not an option. I deleted following directories, and could start afresh!
.metadata
.buildpath
.project
Hope this helps you as well.
Please note that you will end up loosing all the project settings.
I know my reply is too late. Hope this helps another user.
My Ubuntu in the VMware was shutdown abnormally for some reason. When I logged back in Eclipse would not start. I fixed with the following steps:
removed .lock file in the .metadata folder in the workspace
started eclipse using command line with "-clean" argument
It started fine!!!
I tried to find the corrupted file by removing the files from ~/workspace/.metadata/ one by one until Eclipse could start.
The corrupted file was ~/workspace/.metadata/.plugins/org.eclipse.core.resources/.snap
Once the file was removed Eclipse started normally.

Eclipse: The project was not built since the source file ... could not be read

When compiling my Java project, I get this error in Other errors:
Description Resource Path Location Type
The project was not built since the source file /PROJECT/src/main/org/../ABC.java could not be read PROJECT Unknown Java Problem
Indeed, the file is listed in Package Explorer but shows only "Error retrieving content description. On the file system, the silent dir exists but not the file; git status is missing nothing. How do I resolve that compile error?
Simply restart eclipse, refresh all projects and do a clean build. That should fix it. Don't forget the eclipse restart, else no matter how many times you do a clean build or refresh, it will not fix the problem
Looks like someone has deleted that file but eclipse still think that file is part of the project. Might have happened when someone deleted a file from the source control in an improper way.
If you dont have pending changes then you can get fresh copy of the project and import it into your workspace.
If you have pending changes then take a copy of changes and repeat above step. ( A restart of eclipse may be necessary)
It can be related to missing location
Select File => properties => Resource => Edit file location.
I know the answer is accepted but in my case that solution didn't work for me, I had restored files from a backup to my local project in linux and the files I restored were owned by root with only the owner being able to read/write the files. SO, I sudo chowned the files "sudo chown _R myUser:myUser *" at the base of my project, refreshed in Eclipse (f5) and the annoying repeated failure of my build was a thing of the past.
If you are writing Maven projects, try right click on the project and select [Maven] -> [Update Project...]
It works for me.
For me there was a different solution than mentioned here.
I was doing a no-no, I imported a project that had a .project file, and there was some errors in the way my version of eclipse was reading some of the files. The package names and files had a little ! symbol with a yellow background.
The solution was to delete the packages. Obviously make a backup. But in doing this most times the files nor the packages were deleted. Instead eclipse refreshed and the desired files were there. Sometimes I had to hit refresh (F5), and sometimes I had to restore files.
I found it best to delete the packages as that is where eclipse was having reading the data.
If the missing file is still mentioned in the Linked Resources, no refresh and restart of Eclipse will ever solve the problem. You have to delete the file in the Project Properties Linked Resources list.
For anyone using VS Code with the RedHat Java plugins (which use Eclipse tooling under the hood), I got this error as well. I fixed with the following:
# Quit VS Code
rm -rf ~/Library/Application\ Support/Code/User/workspaceStorage/*
# Reopen VS Code
As all others said, it is most probably an issue with the internal caches of Eclipse.
I usually restart the IDE with the additional -clean option to wipe out the OSGi-related caches, then clean and rebuild all the projects.
If the problem persists, I realized that cleaning up the single affecting project works better that cleaning up the whole workspace. (Ominous... XD)
This usually happens to me when merging changes that imply renaming or deletion of source files, prior to launching Eclipse.

Where does Eclipse save the list of files to open on startup?

Question: where does Eclipse store the list of files it opens on startup?
Background: Having installed a plugin into Eclipse which promptly crashed, my Eclipse workspace is in a bit of a state. When started, the building workspace task pauses indefinitely at 20%. Before I uninstall the plugin I want to give it another chance. I have a feeling that the reason Eclipse is pausing is because of a file which was opened when it crashed, which it tries to reopen on startup. If I can stop this file from opening on startup there's a chance I may be able to coax the plugin to behave. The problem is I have no idea where that list of files is persisted between runs of Eclipse.
...a second before I posted this question, I realised I could just delete the file causing the problem (duh). However, the search has frustrated me enough to want to find the answer.
In your workspace the following file contains your workbench information:
.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml
It is possible to delete it (or edit it but that requires some fiddling around I suppose) without breaking your workspace, the file gets regenerated by Eclipse. When you delete it all workbench related settings are lost (ie all editors are closed), but your projects of that workspace stay intact.
Edit: in Eclipse 4.2 the file is
.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi