There is a new KNIME forum. You can still browse and read content from our old forum but if you want to create new posts or join ongoing discussions, please visit our new KNIME forum: https://forum.knime.com

Use Knime API in Java plugin

Member for

9 months 1 week MassimoB

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: 

Comments
Sat, 10/07/2017 - 10:20

Member for

11 years 5 months

thor

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

Mon, 10/09/2017 - 04:40

Member for

9 months 1 week

MassimoB

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!