Use Knime API in Java plugin

Hi Everybody,

I am triyng to use Knime API in my java plug in. What I am trying to do is to call a workflow from a java class.

I have a button in my UI that trigger this method:

(I don't know if it is correct I didn't find any example on the web about how to use knime API) 

 

    public void testKnime(){
            File dir = new File("my path to KNIME_project");
            ExecutionMonitor exec = new ExecutionMonitor();
            WorkflowLoadHelper helper = new WorkflowLoadHelper();
            try {
                WorkflowLoadResult result = WorkflowManager.loadProject(dir, exec, helper);
            } catch (IOException | InvalidSettingsException | CanceledExecutionException
                    | UnsupportedWorkflowVersionException | LockFailedException e) {
                e.printStackTrace();
            } catch (SecurityException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }    
        }

When I create an instance of ExecutionMonitor I receive in console the message "Can't locate CorePlugin, not an OSGi framework?"

And then the error:

[EDIT]

WARN  main WorkflowManager No workflow context available for null

ERROR main FileWorkflowPersistor Unable to load node with ID suffix 2 into workflow, skipping it: java.lang.NoClassDefFoundError: org/eclipse/equinox/p2/metadata/IInstallableUnit

ERROR main FileWorkflowPersistor Unable to load node with ID suffix 3 into workflow, skipping it: java.lang.NoClassDefFoundError: 

ERROR main FileWorkflowPersistor Unable to load node with ID suffix 4 into workflow, skipping it: java.lang.NoClassDefFoundError: 

ERROR main FileWorkflowPersistor Unable to load node with ID suffix 6 into workflow, skipping it: java.lang.NoClassDefFoundError: 

ERROR main FileWorkflowPersistor Unable to load node with ID suffix 7 into workflow, skipping it: java.lang.NoClassDefFoundError: 

ERROR main FileWorkflowPersistor Unable to load node with ID suffix 8 into workflow, skipping it: java.lang.NoClassDefFoundError: 

ERROR main FileWorkflowPersistor Unable to load node with ID suffix 9 into workflow, skipping it: java.lang.NoClassDefFoundError: 

You cannot use KNIME plug-ins outside of an OSGI framework. They strictly require OSGi for dependency resolution.

Hi Thor,

thank you for your reply...I have created a new plug in and now it works, I guess it was a dependencies conflict!

If I am not wrong eclipse RCP plugins are based on OSGI!