Java Snippet - adding an external JAR lib causes the node to fail.

Hi,

Using KNIME 2.3.0 on Windows XP. I can happily execute a Java snippet that appends a column with this code:

return "dummy string";

But as soon as I add an external JAR dependency on the "Additional Libraries" tab my node goes to the "red" state with a warning sign above the "traffic light" and I can't do anything with it. When the JAR dependency is removed, the node works again.

I have even tried adding one of the JAR files from KNIME's jre\lib\ or plugins\ directories (in case there were some KNIME-specific requirements on the JAR contents) but that doesn't work either.

This seems really basic - what am I doing wrong ?

Cheers

-- Jan Holst Jensen

OK, I now see that there is some output in the console when the node fails. "org.knime cannot be resolved" - is the classpath totally messed up by adding the JAR ?

Here goes, console output:

WARN      Java Snippet     Unable to compile expression
ERROR at line 8
AbstractSnippetExpression cannot be resolved to a type

ERROR at line 6
The import org.knime cannot be resolved

ERROR at line 7
The import org.knime cannot be resolved

ERROR at line 12
Abort cannot be resolved to a type

ERROR at line 12
The method internalEvaluate() of type Expression95 must override or implement a supertype method

 

Thanks for reporting this. I can confirm the jar file support isn't working in v2.3.0 (we changed the code compilation in v2.3.0 -- this might be related).

We have fixed this for v2.3.1 and added a test case. v2.3.1 is going to be released soon (certainly in January).

Thanks again!

Thanks for the swift response. Can I access a prerelease of 2.3.1 anywhere or should I revert to 2.2.2 to get this working now ?

Cheers

-- Jan

I have downloaded 2.2.2 and can now add a JAR dependency without blowing up the node. However, I am still unable to make it work.

I have created the simple test class MyClass.java which goes like this:

package com.myorg;

public class MyClass {

    public String testMe()
    {
        return "Hello from MyClass.";
    }
}

and put that in the JAR TestLib.jar. It runs fine when I use it with this test program:

import java.io.*;

public class test {

    public static void main(String argv[]) {
        com.myorg.MyClass mc = new com.myorg.MyClass();
        System.out.println(mc.testMe());
    }
}

and run that with "java -cp .;TestLib.jar test".

I then try to run it from within KNIME with a Java Snippet that has TestLib.jar added as an Additional Library and the following two lines of code in its Method Body:

com.myorg.MyClass mc = new com.myorg.MyClass();
return mc.testMe();

The snippet compiles fine, but when run I get these warnings in the KNIME console:

WARN      ColumnCalculator     Evaluation of expression failed for row "Row0": com/myorg/MyClass

for each row that I put through.

I am a little confused now ...

Cheers, Jan Holst Jensen

... there was yet another problem with Linux vs. Windows, which we fixed. KNIME v2.3.1 should come out shortly, so if you can wait, wait.

If you can't wait you can try copying the jar files into the jre-folder contained in the KNIME installation directory. The files need to go into <knime_install_dir>/jre/lib/endorsed (you need to create the endorsed folder.) The list of jar files in the java snippet node can be left empty in that case.

I tried copying the JAR file into the "endorsed" folder and I can now compile the code in the Java Snippet without having to set a path to the JAR file. So far so good.

It still gives me the same evaluation error though so the output of the Java Snippet node ends up being NULL again.

So I guess I'll wait for 2.3.1 :-).

Cheers

-- Jan

You would leave the jar list in the Java Snippet node empty as the jars are now part of the global class path.

... or you would just wait for 2.3.1 (we are currently building).

Cheers,

 Bernd

Marvellous! 2.3.1 seems to work fine. Thanks :-).

Cheers // Jan Holst Jensen

Cool. Thanks to you for reporting this!