How can i start OSGI framework from a plugin

If i try to start a bundle like this from simple class in the main method everything works fine:

FrameworkFactory fFactory = ServiceLoader.load(FrameworkFactory.class).iterator().next(); //line 1
Framework framework = fFactory.newFramework(config);
context = framework.getBundleContext();
bundle = context.installBundle(myBundle);

But if i do the same thing when the first file is opened, it dosn't work.

import org.osgi.framework.launch.FrameworkFactory;

public class MyEditor implements FileEditor, FileEditorManagerListener {
        private final VirtualFile file;
        private final Project project;

    static {
        FrameworkFactory frameworkFactory = ServiceLoader.load(FrameworkFactory.class).iterator().next(); // line 44

I get this error:

  ERROR - com.intellij.ide.IdeEventQueue - Error during dispatching of java.awt.event.MouseEvent[MOUSE_RELEASED,(120,238),absolute(186,238),button=1,modifiers=Button1,clickCount=2] on frame0
java.util.ServiceConfigurationError: org.osgi.framework.launch.FrameworkFactory: Provider org.eclipse.osgi.launch.EquinoxFactory not a subtype
     at java.util.ServiceLoader.access$300(
     at java.util.ServiceLoader$
     at java.util.ServiceLoader$
     at myPackage.MyEditor.(

Original message URL:

Please sign in to leave a comment.