constructor - Using external java library in KNIME. Why initialization of one class fails while it succeeds for another class? -
i have problem integrating java code knime. similar posts on knime forum (http://tech.knime.org/forum/knime-general/using-external-jar-in-java-snippet-node-workflow-not-able-to-initialize-class-of) of little , posted question there have not got answer far, i'm trying luck here.
i trying integrate code knime workflow using javasnippet. have exported code jar , put knime jre/lib/endorsed folder. code references cdk 1.4.19 , have placed corresponding jar file same directory. not have cdk node extensions installed in knime , using them not option in case.
the code starts with:
ichemobjectbuilder builder = silentchemobjectbuilder.getinstance(); smilesparser sp= new smilesparser(builder);
when try execute javasnippet following exception message:
evaluation of java snippet failed row "row0". exception message: not initialize class org.openscience.cdk.smiles.smilesparser
when try
ichemobjectbuilder builder = silentchemobjectbuilder.getinstance();
it works , no exception message. have checked, builder not null. however, when try initialize smilesparser, fails. class public. has no default constructor , has 1 public constructor takes ichemobjectbuilder parameter.
i have tried use class loader:
url[] classloaderurls = new url[]{new url("file:///path on computer/knime_2.9.4/jre/lib/endorsed/cdk-1.4.19.jar")}; urlclassloader urlclassloader = new urlclassloader(classloaderurls); class<?> parserclass = urlclassloader.loadclass("org.openscience.cdk.smiles.smilesparser"); class[] classparameters = new class[] {ichemobjectbuilder.class}; constructor<?> constructor = parserclass.getconstructor(classparameters); //until line there no problems object parser = constructor.newinstance(builder); //fails here same exception message: not initialize class org.openscience.cdk.smiles.smilesparser
i sure not cdk error because can execute code in eclipse.
why can constructor of 1 class called knime without problems , constructor of class can not??
i grateful if suggest solution or probable reason why happens.
thank you!
ok, solved problem myself. cleaned project meta data, cleaned endorsed library directory, switched knime workspace directory, put jars 1 folder , added them external libraries. works:)
Comments
Post a Comment