Classpath issues with Jackson in KNIME

Hi all,

I am having trouble to deserialize JSON in KNIME but the same code works outside KNIME in a unittest.

The design is fairly simple. An interface EnvironmentManager with a single getEnvironment method that prepares an environment where to run a model. This interface is implemented by,

In my workflow, the environment of a model stored in a JSON file in the port object looks like:

  "archivePath":"C:\\Users\\de\\knime_workspace\\simple\\FSKX Reader (#1)\\drop\\201912090707_PiresOutbLA2011-Salmonella.fskx",

This instance can be deserialized with this snippet which fails when I include it in the load method of the serializer of my port object.

File file = new File("C:/Users/de/Desktop/workingDirectory");
EnvironmentManager deserializeManager = mapper.readValue(file, EnvironmentManager.class);

This snippet throws InvalidTypeIdException with message

Could not resolve type id ā€˜de.bund.bfr.knime.fsklab.nodes.environment.ArchivedEnvironmentManagerā€™ into a subtype of [simple type, class de.bund.bfr.knime.fsklab.nodes.environment.EnvironmentManager]: no such class found

Thanks a lot!

This sounds similar to an issue Iā€™ve had a few years ago (so a bit hazy on the details). I think my issue was caused by OSGi classpaths and Jackson not having access to the classes provided in another plugin which are provided by a different ClassLoader(?).

Sorry itā€™s not more helpful but maybe a pointer in the right direction?



1 Like

Yes, that seems to be the case, especially considering you wrote this:

Where is the Jackson library located? Are you loading it from a bundle?


Thanks Gabriel and Sam,

I am loading Jackson from the KNIME target with the dependencies


For testing separatedly out of KNIME I included in this unittest the snippet above to read the JSON from a file

The out of KNIME test that works is still using an OSGi dependency for jackson?

That to me would indicate itā€™s not inherently an issue through loading in different OSGi plugins then unless this is handled different for the test code.

Iā€™d be tempted to test out quickly deploying jackson libs manually into your plugin doing the deserialisation just to double check though.

Again sorry itā€™s not particularly helpful

You can test the eclipse dependency resolution / classloading if your run the unit test as a Junit plug-in test. That is an option that should be available to you in the run as context menu.


I fixed it!

I had to remove the JsonSubTypes annotation. Maybe I made an error there but Jackson still deserializes even without it.

@JsonTypeInfo(use = Id.CLASS, include = As.PROPERTY)
//  @Type(value = ExistingEnvironmentManager.class, name="ExistingEnvironmentManager"),
//  @Type(value = ArchivedEnvironmentManager.class, name="ArchivedEnvironmentManager"),
//  @Type(value = FilesEnvironmentManager.class, name="FilesEnvironmentManager")
public interface EnvironmentManager {
  Optional<Path> getEnvironment();



This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.