“还没有创建Workbench” eclipse插件编程中的错误

问题描述:

随着我的eclipse插件启动,我得到 Root异常:java.lang.IllegalStateException:尚未创建Workbench。错误。

With my eclipse plugin launching, I got Root exception:java.lang.IllegalStateException: Workbench has not been created yet. error.

并且它似乎会导致副作用使一些包异常错误。我不认为我的代码使用egit模块。

And it seems to cause side effect to make some bundle exception error. I don't think my code uses egit module.

org.osgi.framework.BundleException: Exception in org.eclipse.egit.ui.Activator.start() of bundle org.eclipse.egit.ui.
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:734)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
    at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:300)

如何删除此错误?这是访问工作区的代码。我发现这篇文章 - 调试失败的Eclipse启动说它是竞争条件,但我不确定为什么我有竞争条件,如果有,如何删除它。

How can I remove this error? This is the code that accesses the workspace. I found this article - Debugging a failed Eclipse launch saying that it's race condition, but I'm not sure why I have race condition, and if so, how to remove it.

public void renameClassRefactor() throws CoreException {
    // get the project information with ResourcesPlugin
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    // 1. The name of the project in the workspace

    System.out.println(ResourcesPlugin.getWorkspace().toString());
    java.io.File workspaceDirectory = root.getLocation().toFile();
    System.out.println(workspaceDirectory.toString());


参考这个网站,我可以在Run中添加 -clean 参数配置以删除错误消息。

Referring to this site, I could add -clean parameter in Run Configuration to remove the error message.