Community
Participate
Working Groups
After making some changes to the source code in my Java project, I hit CTRL+SHIFT+S to save. Got an error "Unable to restore CommandImpl.java" (one of the sourcefiles). The project folder was now empty except for the .project file. All other files (significant amount of work) had been deleted.
This message means that Eclipse was unable to reopen an editor on a file which was supposed to exist. How did your files disappear ? Did the package explorer still show them at this point, but nothing was left on the disc ? Was autobuild on (i.e. Window>Preferences>Workbench>Perform build automatically on resource modification) ? Could you provide us with steps to reproduce ?
Autobuild was in fact on. (Most of my settings are still default at this point) The files were showing in the package explorer immediately before I attempted to save; they were not there immediately after the error. The only potentially significant detail I could add is that the project I was working on had been coded with JBuilder originally. I had copied the source only over to the new Eclipse project folder and imported the source into the project. I had been working without problems on the source for a couple hours at the time of the error.
What are your settings for the .classpath file? Did you use source folders? Different output folders?
Do you have any information in your .log file ? On the surface it feels something bad occurred, causing the project to default to an empty classpath, and since autobuild was on, it would consider it should empty it completely. We'd like to understand how this is possible. Need to investigate.
The classpath was completely vanilla: only project classes and standard java classes were used. There were two folders under the project folder: src and classes for source and compiled output respectively. I have performed a thorough search of my harddrive and have been unable to find a .log file. Could it have a different name on my systems? Is it the default to have this feature enabled?
The .log file should reside inside your workspace, under: <workspace>/.metadata/.log When you say 'only project classes', do you mean the project was acting as a source folder ? Also did you recall where your output location was pointing at, directly to the project or a separate 'bin' folder ?
All project source was in the src folder under the project folder. All compiled classes were in the classes folder under the project folder. The classes folder would have been on the classpath. I guess my thorough search for the .log wasn't thorough enough. ;-) Here are the relevant log entries from the time of the error: !SESSION Feb 23, 2003 11:36:59.500 --------------------------------------------- java.version=1.4.1_01 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US Command-line arguments: -os win32 -ws win32 -arch x86 -install file:C:/Eclipse/ !ENTRY org.eclipse.jdt.core 4 4 Feb 23, 2003 11:36:59.500 !MESSAGE JavaBuilder handling ImageBuilderInternalException !STACK 1 org.eclipse.core.internal.resources.ResourceException: Resource /A3/src does not exist. at org.eclipse.core.internal.resources.Resource.checkExists (Resource.java:179) at org.eclipse.core.internal.resources.Resource.accept(Resource.java:57) at org.eclipse.core.internal.resources.Resource.accept(Resource.java:40) at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.copyExtraResourcesBack (BatchImageBuilder.java:116) at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.scrubOutputFolder (BatchImageBuilder.java:88) at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.build (BatchImageBuilder.java:33) at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildAll (JavaBuilder.java:170) at org.eclipse.jdt.internal.core.builder.JavaBuilder.build (JavaBuilder.java:103) at org.eclipse.core.internal.events.BuildManager$2.run (BuildManager.java:392) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:839) at org.eclipse.core.runtime.Platform.run(Platform.java:416) at org.eclipse.core.internal.events.BuildManager.basicBuild (BuildManager.java:120) at org.eclipse.core.internal.events.BuildManager.basicBuild (BuildManager.java:176) at org.eclipse.core.internal.events.BuildManager.basicBuild (BuildManager.java:186) at org.eclipse.core.internal.events.BuildManager$1.run (BuildManager.java:146) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:839) at org.eclipse.core.runtime.Platform.run(Platform.java:416) at org.eclipse.core.internal.events.BuildManager.basicBuild (BuildManager.java:160) at org.eclipse.core.internal.events.BuildManager.build (BuildManager.java:211) at org.eclipse.core.internal.resources.Workspace.endOperation (Workspace.java:745) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1383) at org.eclipse.ui.actions.WorkspaceModifyOperation.run (WorkspaceModifyOperation.java:78) at org.eclipse.ui.texteditor.AbstractTextEditor.performSaveOperation (AbstractTextEditor.java:2329) at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.performSaveOperatio n(CompilationUnitEditor.java:664) at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.doSave (CompilationUnitEditor.java:712) at org.eclipse.ui.internal.EditorManager$11.run(EditorManager.java:1004) at org.eclipse.ui.internal.EditorManager$8.run(EditorManager.java:873) at org.eclipse.jface.operation.ModalContext.runInCurrentThread (ModalContext.java:299) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:249) at org.eclipse.jface.window.ApplicationWindow$1.run (ApplicationWindow.java:394) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:66) at org.eclipse.jface.window.ApplicationWindow.run (ApplicationWindow.java:391) at org.eclipse.ui.internal.WorkbenchWindow.run (WorkbenchWindow.java:1126) at org.eclipse.ui.internal.EditorManager.runProgressMonitorOperation (EditorManager.java:879) at org.eclipse.ui.internal.EditorManager.saveEditor (EditorManager.java:1009) at org.eclipse.ui.internal.WorkbenchPage.saveEditor (WorkbenchPage.java:1990) at org.eclipse.ui.internal.SaveAction.run(SaveAction.java:32) at org.eclipse.jface.action.Action.runWithEvent(Action.java:749) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:47) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:77) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:827) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1529) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1291) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1343) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1326) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:831) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:462) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:247) at org.eclipse.core.launcher.Main.run(Main.java:703) at org.eclipse.core.launcher.Main.main(Main.java:539) !ENTRY org.eclipse.core.resources 4 368 Feb 23, 2003 11:36:59.770 !MESSAGE Resource /A3/src does not exist. !ENTRY org.eclipse.ui 4 4 Feb 23, 2003 11:37:00.160 !MESSAGE Unable to restore editor - createElement returned null for input element factory: org.eclipse.ui.part.FileEditorInputFactory !ENTRY org.eclipse.ui 4 4 Feb 23, 2003 11:37:00.320 !MESSAGE Unable to restore editor - createElement returned null for input element factory: org.eclipse.ui.part.FileEditorInputFactory
Just to make it clear, could you recreate an empty project and set it up as you did initially (when you saw the problem). Then please paste in this PR, the contents of the .classpath file (in the project folder, may need to be revealed by disabling .* filter in navigator/package explorer).
<?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> <classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/> <classpathentry kind="output" path="classes"/> </classpath>
I am investigating.
Have you seen such a problem with a 2.1 build as well or just with a 2.0.2 build? The problem is that your stacktrace is completely different now.
I only use build 2.0.2. I have only seen this problem once even with 2.0.2. The stacktrace is completely different from what?
I meant that this code completely changed since 2.0.2. In 2.1, exclusion filters have been added and the code of the builder is quite different. I will investigate in 2.0.2 and try to see if I can reproduce in 2.1.
Do you remember if you changed the output folder or edited the .classpath file yourself? I am trying to find some steps to reproduce in order to understand how you ended up losing source files.
As mentioned previously, the source code was originally from a JBuilder project; I copied over the source folder (with ONLY *.java files) to the new folder (which was NOT under the workspace folder but under my C:\ directory, if that helps.) I do vaguely recall having some difficulty at first getting the project to recognize the new source folder; it is possible that I fixed the problem by manually changing the source folder definition in the .classpath, but I can't say for sure. At the time of the error, I had been working in the project for a couple hours, saving frequently. The error occured on the first occasion that I used Save All that I know of (again, if that helps). I don't recall having made any changes to the project metadata just before the error.
I was able to reproduce in 2.0.2 with the following steps: 1. Start new workspace (autobuild is on) 2. Create Java project with 1 src folder and 1 bin folder 3. Add class X in src folder 4. Edit .classpath file so as to make the output entry point to the project: <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> <classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/> <classpathentry kind="output" path=""/> </classpath> 5. Exit/restart project 6. Change class X to add a field and save Observe: All files in the project are removed
Problem still exists in 2.1, even if after step 4 a build path error marker is created which should prevent the builder from running.
Removed the builder scrubbing output in presence of a broken classpath. Backported to 2.0.x stream for upcoming rollup.
Fixed
Added regression tests OutputFolderTests.testInvalidOutput() to 2.0.x and 2.1 streams.
Verified.