问题
With my eclipse plugin launching, I got Root exception:java.lang.IllegalStateException: Workbench has not been created yet.
error.
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)
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());
回答1:
I struggled a lot for “Workbench has not been created yet” the complete day.
But I got the solution by the following steps.-
- Go to the Run configuration -> Remove all the target platform jars.
- Click on add required bundles.
- Check the
org.apache.felix.gogo.runtime
,org.apache.felix.gogo.shell
,org.eclipse.equinox.console
,org.eclipse.osgi
and your jar file. - The last and important step. Go to Setting-> check the checkbox of "Clear the configuration area before launching".
- Run the OSGi application now.
- Enjoy if it works for you as it worked for me.
Thanks
回答2:
Referring to this site, I could add -clean
parameter in Run Configuration to remove the error message.

来源:https://stackoverflow.com/questions/13773582/workbench-has-not-been-created-yet-error-in-eclipse-plugin-programming