Java &引用;“工作台尚未创建”;eclipse插件编程中的错误

Java &引用;“工作台尚未创建”;eclipse插件编程中的错误,java,eclipse,plugins,workspace,Java,Eclipse,Plugins,Workspace,启动eclipse插件后,我得到了根异常:java.lang.IllegalStateException:Workbench尚未创建。错误 而且它似乎会导致一些包异常错误的副作用。我认为我的代码没有使用egit模块 org.osgi.framework.BundleException: Exception in org.eclipse.egit.ui.Activator.start() of bundle org.eclipse.egit.ui. at org.eclipse.osgi.

启动eclipse插件后,我得到了
根异常:java.lang.IllegalStateException:Workbench尚未创建。
错误

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

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)
如何删除此错误?这是访问工作区的代码。我发现说这是种族条件,但我不确定为什么我有种族条件,如果有,如何删除它

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());
参考,我可以在运行配置中添加
-clean
参数来删除错误消息


为了“工作台尚未创建”这一整天,我做了很多努力

但我通过以下步骤得到了解决方案-

  • 转到运行配置,移除所有目标平台JAR
  • 单击add required bundles
  • 检查
    org.apache.felix.gogo.runtime
    org.apache.felix.gogo.shell
    org.eclipse.equinox.console
    org.eclipse.osgi
    和您的jar文件
  • 最后也是重要的一步。转到设置-选中“启动前清除配置区域”的复选框
  • 现在运行OSGi应用程序
  • 如果它对你和对我都有效,那就享受吧
  • 谢谢