# Cannot access classes from org.knime.core bundle in Java Snippet node

**URL:** <https://forum.knime.com/t/cannot-access-classes-from-org-knime-core-bundle-in-java-snippet-node/85754>\
**Category:** KNIME Analytics Platform\
**Tags:** java-snippet, bug\
**Created:** [January 14, 2025, 4:50pm UTC](https://forum.knime.com/t/cannot-access-classes-from-org-knime-core-bundle-in-java-snippet-node/85754 "2025-01-14T16:50:41Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![s.roughley](https://forum-cdn.knime.com/user_avatar/forum.knime.com/s.roughley/32/366_2.png) [@s.roughley](https://forum.knime.com/u/s.roughley)\
**Post date:** [January 14, 2025, 4:50pm UTC](https://forum.knime.com/t/cannot-access-classes-from-org-knime-core-bundle-in-java-snippet-node/85754/1 "2025-01-14T16:50:42Z")

</div>

Hi,

I have been trying to access various classes from the `org.knime.core` bundle via a Java Snippet.

I have added the bundle under the ‘Additional Bundles’ tab, but can only import the classes `org.knime.core.node.KNIMEConstants` and `org.knime.core.node.NodeLogger`.

I can see a number or related tickets which seem to have gone unanswered:

> [@Can't access CDK bundle in Java Snippet node](https://forum.knime.com/t/cant-access-cdk-bundle-in-java-snippet-node/71464):
>
> Hi, I’d like to include the CDK library in a Java Snippet node. In the node I go to the Additional Bundles tab and select the org.openscience.cdk.knime bundle: [image] Then in the Java Snippet tab, I try to import “org.openscience…” but it cannot be resolved: [image] Any idea what the issue is? Thanks, -Don

> [@Unable to Use org.knime.core.node.workflow.WorkflowManager Library in Java Snippet](https://forum.knime.com/t/unable-to-use-org-knime-core-node-workflow-workflowmanager-library-in-java-snippet/84171):
>
> I want to use methods from the org.knime.core.node.workflow.WorkflowManager library. I can successfully work with the org.knime.core.node.NodeLogger library, but I am unable to connect to WorkflowManager. KNIME Analytics Platform v4.7.2.v202303231026 The code that I will run using the required library: public void saveWorkflowState() { try { org.knime.core.data.columnar.schema.ColumnarValueSchemaUtils // Getting the main Workflow Manager object for accessing the workflow …

Is there a solution to this problem, or even an open ticket on it?

@ipazin @wiswedel

Thanks

Steve

---

<div class="post-metadata">

**Author:** ![ipazin](https://forum-cdn.knime.com/user_avatar/forum.knime.com/ipazin/32/806_2.png) [@ipazin](https://forum.knime.com/u/ipazin)\
**Post date:** [January 16, 2025, 7:24am UTC](https://forum.knime.com/t/cannot-access-classes-from-org-knime-core-bundle-in-java-snippet-node/85754/2 "2025-01-16T07:24:36Z")

</div>

Hello @s.roughley,

can’t help you unfortunately. Maybe @ScottF will be able to find more information?

Br,  
Ivan

---

<div class="post-metadata">

**Author:** ![ScottF](https://forum-cdn.knime.com/user_avatar/forum.knime.com/scottf/32/61316_2.png) [@ScottF](https://forum.knime.com/u/ScottF)\
**Post date:** [January 16, 2025, 7:41pm UTC](https://forum.knime.com/t/cannot-access-classes-from-org-knime-core-bundle-in-java-snippet-node/85754/3 "2025-01-16T19:41:58Z")

</div>

Hi @s.roughley -

Let me ask internally and see what I can find out.

---

<div class="post-metadata">

**Author:** ![BenjaminMoser](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@BenjaminMoser](https://forum.knime.com/u/BenjaminMoser)\
**Post date:** [January 31, 2025, 4:07pm UTC](https://forum.knime.com/t/cannot-access-classes-from-org-knime-core-bundle-in-java-snippet-node/85754/4 "2025-01-31T16:07:48Z")

</div>

Hey @s.roughley ,

sorry for the late reply.

I right now cannot give you details on why exactly this is not available in the Java Snippet node as expected.

I can say however, that it has to do with the way the org.knime.core plugin/bundle is represented on disk (in p2 terms, how it is installed in the resp. bundle pool). Concretely, if you look in the AP installation directory in the folder `plugins`, you’ll see that some plugins are jars and some are directories.

If they are directories, they will (always, as far as I can see, and certainly for sure in the case of org.knime.core) contain a correponding jar file. That file is already set as the `Bundle-ClassPath` in the `Manifest.MF`.

Based on this, I can offer you the workaround to add that jar file under “Additional Libraries” instead of including it in “Additional Bundles”.

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/0/7/07d4da5d4d6027dc5e85780c8831e32dbdffa1e3.png)

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/4/1/414da1c5f4c4fd79c1afd0c955e4fb86caec74eb.png)

The drawback is that this path contains the bundle version, which means it will change with an update.

However, you can also supply the list of “Additional Libraries” via the flow variable `jarFiles`, so it should be not too hard to add a couple of nodes that query the folder from that directory.

Best,  
Ben

---

<div class="post-metadata">

**Author:** ![takbb](https://forum-cdn.knime.com/user_avatar/forum.knime.com/takbb/32/57077_2.png) [@takbb](https://forum.knime.com/u/takbb)\
**Post date:** [January 31, 2025, 8:45pm UTC](https://forum.knime.com/t/cannot-access-classes-from-org-knime-core-bundle-in-java-snippet-node/85754/5 "2025-01-31T20:45:41Z")

</div>

> [@BenjaminMoser](#):
>
> The drawback is that this path contains the bundle version, which means it will change with an update.

I _may_ be able to help with that… I have a component… 😉

> **[Collect Required Plugin Jars – takbb](https://hub.knime.com/takbb/spaces/Experimental/Collect%20Required%20Plugin%20Jars~MTiFavWubk43D0h6/current-state)**
>
> Locates the selected list of jar files, which can include wildcards from the KNIME plugins folder. The list of file names is returned as the String List flow v…

I already had this component to go try to find bundles to get round the problem of things changing every time there was a new KNIME update, and based on your comments above, I’ve added the option to search subfolders of the bundles for required jars.

It should work the same way with both Java Snippet and Java Edit Variable…

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/f/d/fd96c49ed2fe1c9cc391a83d64702fa98448d8e8.png)

As you can see from the screenshot, when the additional libraries has been specified using the flow variable, the syntax highlighter of the java editor does not recognise that the package is present. However, as you can also see from the node state and the output, it does actually compile and execute , returning the output “(WFM) ROOT (IDLE)” in this case as a flow variable.

So, possibly for editing the java, you’d want to add the required additional library in manually, but then for “shipping”, you could add it in using the flow variable from the “Collect Required Plugin Jars” component.

In the component you specify a file name pattern for it to search, so this kind of becomes an “abstraction layer” instead of being tied to a physical version number.

I have this component in my “experimental” folder on the hub, but its available to try, and happy to get feedback and suggestions if it is helpful.

([background/origin of this component](https://forum.knime.com/t/write-to-excel-template-not-updating-specific-cells-with-formula/83289/9))

---

<div class="post-metadata">

**Author:** ![BenjaminMoser](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@BenjaminMoser](https://forum.knime.com/u/BenjaminMoser)\
**Post date:** [February 3, 2025, 8:35am UTC](https://forum.knime.com/t/cannot-access-classes-from-org-knime-core-bundle-in-java-snippet-node/85754/6 "2025-02-03T08:35:03Z")

</div>

Opened a ticket for the syntax highlighting issue (AP-23917).

---

<div class="post-metadata">

**Author:** ![s.roughley](https://forum-cdn.knime.com/user_avatar/forum.knime.com/s.roughley/32/366_2.png) [@s.roughley](https://forum.knime.com/u/s.roughley)\
**Post date:** [February 3, 2025, 10:14am UTC](https://forum.knime.com/t/cannot-access-classes-from-org-knime-core-bundle-in-java-snippet-node/85754/7 "2025-02-03T10:14:52Z")

</div>

Thanks @BenjaminMoser and @takbb - I was about to try writing something similiar to your approach myself.

I have also come across the syntax highlighting error previously (I used a similar approach to @takbb 's to bring in some maven dependencies in another snippet a while back) - I think it comes about as a result of the variable value substitution of for the settings values in the UI not being replaced until sometime during either the configure or execute phases, so may not be solvable (I think it’s the same issue that means you need to put a nonsense value in some node settings even though you replace it with a meaningful value from the flow variables because the dialog component won’t accept an empty input)

Steve

---

<div class="post-metadata">

**Author:** ![takbb](https://forum-cdn.knime.com/user_avatar/forum.knime.com/takbb/32/57077_2.png) [@takbb](https://forum.knime.com/u/takbb)\
**Post date:** [February 3, 2025, 10:39am UTC](https://forum.knime.com/t/cannot-access-classes-from-org-knime-core-bundle-in-java-snippet-node/85754/8 "2025-02-03T10:39:06Z")

</div>

Hi @s.roughley , glad it’s of use.

With the additional subfolder searching in that component, which I only just added here based on the comments in this thread, it could possibly do with some additional optimisation and/or look at caching the jar location after first execution (on a given KNIME version?), as I think this may otherwise add an unwelcome delay, so will be interested to know how you get on, or if you make other refinements to it, or have suggestions.

Good point about the likely problem with the flow variable. I hadn’t thought about it in terms of maybe needing a populated placeholder value.

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [February 10, 2025, 10:39am UTC](https://forum.knime.com/t/cannot-access-classes-from-org-knime-core-bundle-in-java-snippet-node/85754/9 "2025-02-10T10:39:46Z")

</div>

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