prosseek
prosseek

Reputation: 190799

"Workbench has not been created yet" error in eclipse plugin programming

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());

Upvotes: 11

Views: 19231

Answers (2)

Shivam
Shivam

Reputation: 389

I struggled a lot for “Workbench has not been created yet” the complete day.

But I got the solution by the following steps.-

  1. Go to the Run configuration -> Remove all the target platform jars.
  2. Click on add required bundles.
  3. Check the org.apache.felix.gogo.runtime, org.apache.felix.gogo.shell, org.eclipse.equinox.console, org.eclipse.osgi and your jar file.
  4. The last and important step. Go to Setting-> check the checkbox of "Clear the configuration area before launching".
  5. Run the OSGi application now.
  6. Enjoy if it works for you as it worked for me.

Thanks

Upvotes: 25

prosseek
prosseek

Reputation: 190799

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

enter image description here

Upvotes: 13

Related Questions