Recommendation for KNIME Development

Lunch ( munch munch munch …)

Ah - you have no ...Plugin class in your plugin:

org/knime/examples/numberformatter:
total 56
drwxr-xr-x  8 loki  staff   256 Nov 29 23:18 .
drwxr-xr-x  3 loki  staff    96 Nov 29 23:18 ..
-rw-r--r--  1 loki  staff   993 Nov 29 23:18 NumberFormatterNodeDialog.class
-rw-r--r--  1 loki  staff  1763 Nov 29 23:18 NumberFormatterNodeFactory.class
-rw-r--r--  1 loki  staff  1822 Nov 29 23:18 NumberFormatterNodeFactory.xml
-rw-r--r--  1 loki  staff  7680 Nov 29 23:18 NumberFormatterNodeModel.class
-rw-r--r--  1 loki  staff  1327 Nov 29 23:18 NumberFormatterNodeView.class
-rw-r--r--  1 loki  staff   607 Nov 29 23:18 default.png
algebraic:plugin_exploded loki$ 

and from your logs (and my logs when i try) :

Caused by: java.lang.ClassNotFoundException: org.knime.examples.numberformatter.NumberFormatterNodePlugin cannot be found by org.knime.examples.numberformatter_1.0.0.201911292318

Oh my oooops - some weirdness.
I followed the instructions I thought to the letter.
created the project following the instructions and exported the .jar file.
Interesting is that the old project from the first time had the .java file in it, but the exported jar file was missing the class.

Anyway I deleted that project, followed the procedure again, and exported the jar file again.
Voila ! the new jar file contained the xxxPlugin.class and the plugin loaded into the generic knime 4.0.1 !!

It didn’t however load into the SDK build of knime as the docs indicated it would.

The last bit I guess is should I be directing my build classpath into the “generic” version locations instead of the locations in the SDK workspace ? Or should I leave both installed, use one for building and the other for testing ?

Also is there a naming convention for plugin jar files and the contained files I should be following?
I didn’t see any docs on that if it is necessary.

Thanks for pursuing this with me.

PK

Hmm… how strange. To recap:

  • in your Eclipse IDE, you have two projects - the sdk-setup, and the example node plugin for the NumberFormatter.
  • the NumberFormatter has all the needed classes, and opening its plugin.xml in Eclipse and building the plugin produces a jar that, when put in the dropins of a downloaded KNIME 4.0.1, results in the node successfully being recognized by KNIME and available in the Node Repository
  • if you launch the development KNIME from Eclipse, it does not have this node in the Node Repository?

I’m confused by the classpath question, and also there ‘should i leave both installed?’ question. Both of what? The plugin project setup by the wizard need much configuration altering once made. ?

Generally the naming convention for Eclipse plugins are the reverse domain name of the organization, followed by whatever the development group thinks makes most sense… if it’s a large company developing many products, ? com.foo.knime.nodes.coolreader ?

Yes ide with the two projects the sdk-setup and the the numberformatter.

If I build the jar in the sdk-eclipse workspace and export the .jar
it loads fine from the KNIME 4.0.1 dropins folder in the separate install.
it also “automagically” loads the project into sdk-eclipse in a way that it is available to the KNIME
run via the eclipse launcher, or a shell script based on what the eclipse launcher does. ( the script
is useful because I can use it in intellij to launch the debugger on KNIME and it’s plugins, and
do so without launching the eclipse UI).

If before I run KNIME from the sdk-eclipse, I remove the numberformatter project from the sdk-eclipseworkspace using the eclipse UI, then close the sdk-eclipse, then put the same plugin jar file built by the project that loads into knime 4.0.1 into the sdk-eclipse/dropins folder then reopen eclipse, and re-launch knime from it neither the sdk-eclipse nor the KNIME spawned from it see the plugin.

The sdk-eclipse ( and it’s knime project) acts as if it doesn’t recognize or try to load anything put into the sdk-eclipse dropins folder no errors no logs, nothing reported, and the osgi console does not list any status for the numberformatter plugin. Possible it is disabled somehow by the knime-setup project and needs configuring?

In any case, at least now, I have a proven valid plugin that works as expected. And if I can figure out how to spawn the KNIME 4.0.1 in the intellij debugger at least we can develop plugins with intellij and launch the debugger using the intellij UI and debugger-editor.

I myself used eclipse for java development for several years until about 8 years ago when I found intellij so much easier to work with :grin:

The classpath question was simply because I thought building against the nightly build KNIME sdk jars (knime 4.0.1) might potentially be incompatible with loading into 4.0.1 - the fact that it works indicates that is not likely a problem and the public API for plugins is unchanged.

Ah yes - thanks for the clarifications!

Yes - this is correct:

  • putting the built plugin jar into your Eclipse’s dropins folder will do nothing useful as far as Eclipse being able to put it into the KNIME you launch from Eclipse. It is only having the plugin project in your Eclipse project explorer and launching KNIME from Eclipse that you then can see the plugin in that version of KNIME.
  • you do technically run the risk of picking up API slated for 4.1.0 that is incompatible with 4.0.2 - but backwards compatibility for the node related API, in particular, is striven for, given how much would break were that to change.

If you add the following two lines to the end of your black-box-KNIME’s knime.ini file, this will get you all ready for a remote debugger connection from IntelliJ (or Eclipse)

-Xdebug
-Xrunjdwp:transport=dt_socket,address=9321,server=y,suspend=y

Ok - Looks like the path is clear and understood now.

On that “todo” for the docs:

After the export has finished, the selected folder will contain a .jar file containing your plugin. To install it into any Eclipse or KNIME Analytics Platform installation, place the .jar file in the dropins folder of the KNIME/Eclipse installation folder. Note that you have to restart KNIME/Eclipse for the new plugin to be discovered. In this example, the node is then displayed at the top level of the node repository in KNIME Analytics Platform.

I would say the above needs to be changed as I take any Eclipse or KNIME Analytics Platform installation to include the eclipse/knime-sdk install. I would either change the docs or enable the dropins discovery and loading.

documentation QA servant here :slight_smile:

2 Likes

Definitely agreed - thanks for the feedback - it has helped me see potholes in the documenting of the process.

1 Like

What is you preferred way to configure the intellij “run/debug” configuration to launch Knime and debug a plugin? It has been suggested I use a “Junit” configuration.

The goal so hitting “debug” in intellij will build, and deploy the plugin, and launch a debug run of knime in one shot.

Everything is working except the last bit :slight_smile:

Ok trying to debug now. If I run “black box” knime with the command below:

  • it puts up the spash screen and the UI - As these are java, should it not wait until I connect to it if suspend=y ?
  • If I try to connect java remote debugging I get connection refused.

“C:\Program Files\KNIME\knime.exe” -Xdebug \ -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=y

BTW looking at java VM postings for java 8 I see:

From Java 5.0, it is better to use the -agentlib:jdwp single option:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1044

does your .exe pass arguments through directly to the VM ?
When trying this it also also does not “suspend” or give me an open listener port.

I also tried:

“C:\Program Files\KNIME\knime.exe” -Xdebug \ -Xrunjdwp:transport=dt_socket,address=localhost:5005,server=y,suspend=y

and:

“C:\Program Files\KNIME\knime.exe” -Xdebug \ -Xrunjdwp:transport=dt_socket,address=8099,server=y,suspend=y

No errors were reported.

(i’m GMT-8) As mentioned above, i put the debug specifications as the last lines of my knime.ini (i usually keep two - like knime.ini_orig and knime.ini_debug and have command line aliases to copy the desired one to knime.ini) - and yes, you should not see the splash screen until the debugger connects.

WRT to your two-ago-post, i’m not fortunate enough to practically use IntelliJ for the KNIME development as i work on core components these days (as opposed to new nodes that i can bolt on an existing KNIME app.)

thanks will try - pardon my thrashing :slight_smile:

Ok this works and hit my breakpoints. stupid me I put argument on command line and not in .ini file. :expressionless:

Good news… nah, not stupid

Ok have the whole thing working (well 99% of the goal)

Some suggestions for knime:

Have a command line argument on the .exe for selecting a .ini file so it is thread-process safe to have different instances running with different configuration settings.

Enabling the “dropins” discovery on the debug-sdk install would really help for non-eclipse build-debug systems as the source and jars (from the knime-sdk) in the build classpath would not be out of sync with the debugger when running knime, the external build would build->deploy to dropins->run. In intellij running via eclipse using the java-VM has the benefit if the knime process crashes while debugging one can use the “stop” menu entry in the IDE instead of having to go and manually find and kill the process.

There is also the added benefit that one doesn’t need two installs, and the eclipse-workspace (default install) with the knime-sdk version in it is per user.

Anyway we are now happily building and debugging in intellij !!

2 Likes