Reputation: 1997
In my RCP app when I close and re-open a PyDev project, PyDev throws an exception on the console complaining that the project resource does not exist. Everything seems to work afterward, but of course I'd like to avoid showing a spurious exception to my users.
As best I can tell from navigating through the stack trace, PyDev's Content Provider expects the project resource to exist, and it does not. Perhaps I'm supposed to call some API in PyDev when I detect a project closing? Or is this a bug? I noticed the problem on version 5.1.2, but upgrading to the latest version (5.4.0) didn't resolve it.
EDIT:
I discovered that opening the project by right-click on project -> Open Project
does not throw the exception. Only when opening the project by double-clicking on it. Double-click on an open project does not cause a problem, only double-click on a closed one. It seems the PyDev re-targeted action (PyOpenPythonFileAction) is being invoked before the framework has a chance to actually open the project.
EDIT2:
Actually it's stranger than that. The retargeted action that throws the exception isPyOpenResourceAction
(but it's the run()
implementation in superclass PyOpenPythonFileAction
where it fails). The exception is thrown at line 110 on if (viewer.isExpandable(container)) {
. The eclipse resource code there is checking the resource type against some flag bits, and I don;t know why it returns false. I put a guard to only check resources that are of type Project and the project exists and is open, and it still fails.
EDIT3:
In PyOpenPythonFileAction
, Wrapping
if (viewer.isExpandable(container)) {
viewer.setExpandedState(container, !viewer.getExpandedState(container));
}
in a UIJob
and giving it a 500 msec delay seems to fix it.
Here is the console output with stack trace. The project that was closed and re-opened is named "site".
!ENTRY org.python.pydev.shared_core 1 1 2016-12-06 16:31:28.037 !MESSAGE Resource '/site' does not exist. !STACK 1 org.eclipse.core.internal.resources.ResourceException: Resource '/site' does not exist. at org.eclipse.core.internal.resources.Resource.checkExists(Resource.java:335) at org.eclipse.core.internal.resources.Resource.checkAccessible(Resource.java:209) at org.eclipse.core.internal.resources.Project.checkAccessible(Project.java:141) at org.eclipse.core.internal.resources.Project.hasNature(Project.java:521) at org.eclipse.core.internal.resources.Project.getNature(Project.java:405) at org.python.pydev.plugin.nature.PythonNature.getPythonNature(PythonNature.java:809) at org.python.pydev.navigator.PythonBaseModelProvider.getChildrenForIResourceOrWorkingSet(PythonBaseModelProvider.java:611) at org.python.pydev.navigator.PythonBaseModelProvider.getChildren(PythonBaseModelProvider.java:535) at org.python.pydev.navigator.PythonModelProvider.getChildren(PythonModelProvider.java:63) at org.python.pydev.navigator.PythonBaseModelProvider.hasChildren(PythonBaseModelProvider.java:510) at org.eclipse.ui.internal.navigator.extensions.SafeDelegateTreeContentProvider.hasChildren(SafeDelegateTreeContentProvider.java:112) at org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider.callNormalHasChildren(NavigatorContentServiceContentProvider.java:444) at org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider.pipelineHasChildren(NavigatorContentServiceContentProvider.java:463) at org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider.access$5(NavigatorContentServiceContentProvider.java:447) at org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider$3.run(NavigatorContentServiceContentProvider.java:413) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider.hasChildren(NavigatorContentServiceContentProvider.java:392) at org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider.hasChildren(NavigatorContentServiceContentProvider.java:436) at org.eclipse.jface.viewers.AbstractTreeViewer.isExpandable(AbstractTreeViewer.java:2128) at org.eclipse.jface.viewers.TreeViewer.isExpandable(TreeViewer.java:538) at org.python.pydev.navigator.actions.PyOpenPythonFileAction.run(PyOpenPythonFileAction.java:110) at org.eclipse.ui.actions.RetargetAction.run(RetargetAction.java:225) at org.eclipse.ui.navigator.CommonNavigatorManager$2.open(CommonNavigatorManager.java:191) at org.eclipse.ui.OpenAndLinkWithEditorHelper$InternalListener.open(OpenAndLinkWithEditorHelper.java:46) at org.eclipse.jface.viewers.StructuredViewer$2.run(StructuredViewer.java:855) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:50) at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:173) at org.eclipse.jface.viewers.StructuredViewer.fireOpen(StructuredViewer.java:852) at org.eclipse.jface.viewers.StructuredViewer.handleOpen(StructuredViewer.java:1169) at org.eclipse.ui.navigator.CommonViewer.handleOpen(CommonViewer.java:451) at org.eclipse.jface.util.OpenStrategy.fireOpenEvent(OpenStrategy.java:278) at org.eclipse.jface.util.OpenStrategy.access$2(OpenStrategy.java:272) at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:313) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5219) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1340) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4553) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4143) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1121) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1022) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:150) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:687) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:604) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148) at my.package.MyApplication.start(MyApplication.java:137) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610) at org.eclipse.equinox.launcher.Main.run(Main.java:1519) at org.eclipse.equinox.launcher.Main.main(Main.java:1492) !SUBENTRY 1 org.eclipse.core.resources 4 368 2016-12-06 16:31:28.095 !MESSAGE Resource '/site' does not exist.
Upvotes: 2
Views: 517
Reputation: 25362
You probably have some reference to a non-existing site
project somewhere in your project configuration (so, please inspect your .project
and .pydevproject
files in the workspace for such a project).
Upvotes: 0