I have a client library written in Java (GitHub - zendesk/basecrm-java: BaseCRM API Client for Java) that I’d like to use in my KNIME workflow. To do this, I have added the library’s JAR and its dependent JARs to a Java snippet node as “Additional Libraries”.
The node runs fine, i.e. it fetches the required data over the Internet using an API endpoint. However, the node fails to run properly every time I need to change the code. The node keeps throwing exceptions until I restart the entire KNIME application. This behaviour happens in KNIME 4.7.7 (Windows 10) and 5.1.0 (Windows 7 and MacOS 13.5.1).
I think it has something to do with the class loading mechanism that KNIME uses to initialise its Java snippet nodes, but I’m unable to debug it further.
Please find attached a workflow consisting of only two nodes that reproduces the error. Steps to reproduce:
Execute the Java snippet node, it should run with no exception message printed to the KNIME console.
Re-configure the node by adding a blank line to its body, e.g. after line 26 (which contains an expression that uses an external JAR)
Execute the node to see the error message in the console: “WARN Java Snippet 3:25 Evaluation of java snippet failed for row “Row0”.The exception is caused by line 26 of the snippet. Exception message (LinkageError): ClassCastException: attempting to castnull to jar:file:/C:/Users/Ilya/knime-workspace/KNIME_project_Ilya_test/data/Additional_JARs/javax.ws.rs-api-2.0.1.jar!/javax/ws/rs/client/ClientBuilder.class”
Save the workflow and restart KNIME.
Open the workflow and execute the Java snippet node - it will run fine, and will keep running fine until you change its configuration again.
Hi @takbb, yes, the exception message looks similar to mine, but as the code in this Java snippet node is able to run without any errors when I restart Knime, I can’t understand why it starts failing after I open and close the configuration dialogue box to simply add or remove a line break, which should make no difference to the Java compiler.
My guess is that something happens to the system settings and/or the runtime environment at this point, which can only be corrected by a complete restart of the Knime application.