Tuesday, July 12, 2011

!MESSAGE The workspace exited with unsaved changes in the previous session; refreshing workspace to recover changes.

This might happen when:
  • sometimes the computer is put for hibernate many times when the eclipse is still working or
  • resources gets called too early before the instance of workspace can be created, or
  • Eclipse did not shutdown correctly.

And eclipse might crash (freeze on splash) with messages like (check workspace\.metadata\.log)

!ENTRY org.eclipse.core.resources 2 10035 2011-07-12 00:32:14.925
!MESSAGE The workspace exited with unsaved changes in the previous session; refreshing workspace to recover changes.

It might need to starting everything with a new workspace and then set up all the projects again properly (takes hours to do). Some solutions that can be worth trying :
  1.  remove folder workspace\.metadata\.plugins\org.eclipse.core.resources\.root\.indexes
    and restart Eclipse (Referenced here) . Good to rename rather than delete because some also metioned that there was some other problem after that.
  2.  Go to:
    \.metadata\.plugins\org.eclipse.core.resources and remove the file .snap

    Or remove file : .metadata\.plugins\org.eclipse.core.resources\.projects\<project>\.markers.snap . This is a large snapshot file which Eclipse constantly polls for some projects. (Referenced from here )
  3. The third solution (which worked for me) is  when workbench is restarted/quit, then its need to save the workspace, before existing the workbench then the above message comes.
    Overload the preWindowShellClose() method in your of WorkbenchWindowAdvisor. You can save the workspace by using ResourcesPlugin.getWorkspace().save(...) method. (Sited here)
    import org.eclipse.core.resources.ResourcesPlugin;
    import org.eclipse.core.runtime.CoreException;
    import org.eclipse.ui.application.WorkbenchWindowAdvisor;

    public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {

       // other methods...

       @Override
       public boolean preWindowShellClose() {
          try {
             // save the full workspace before quit
             ResourcesPlugin.getWorkspace().save(true, null);
          } catch (final CoreException e) {
             // log exception, if required
          }

          return true;
       }

    }

5 comments:

  1. 2nd solution worked for me!

    Thanks so much

    ReplyDelete
  2. None of the above. Thanks for the help, though.

    ReplyDelete
  3. My solution was to delete the whole .metadata folder. I'm sure that's more than what was needed, but it worked.

    ReplyDelete
  4. 2nd solution worked for me, too!
    thanks a lot!!

    ReplyDelete
  5. 2nd solution worked for me as well. That just costed me 2 days.

    ReplyDelete