# java.lang.ClassNotFoundException: org.eclipse.paho.client.mqttv3.MqttCallbackExtended

**URL:** <https://forum.inductiveautomation.com/t/java-lang-classnotfoundexception-org-eclipse-paho-client-mqttv3-mqttcallbackextended/80853>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [October 23, 2023, 2:36pm UTC](https://forum.inductiveautomation.com/t/java-lang-classnotfoundexception-org-eclipse-paho-client-mqttv3-mqttcallbackextended/80853 "2023-10-23T14:36:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlbertAG](https://avatars.discourse-cdn.com/v4/letter/a/8797f3/32.png) [@AlbertAG](https://forum.inductiveautomation.com/u/AlbertAG)\
**Post date:** [October 23, 2023, 2:36pm UTC](https://forum.inductiveautomation.com/t/java-lang-classnotfoundexception-org-eclipse-paho-client-mqttv3-mqttcallbackextended/80853/1 "2023-10-23T14:36:53Z")

</div>

Good afternoon.

I'm trying to use a **java library** in Ignition to manipulate **MQTT** messages through **protobuf**.  
The library is called _ **tahu** _: [https://github.com/eclipse/tahu/tree/master/java](https://github.com/eclipse/tahu/tree/master/java).  
I was able to build it without problems following the instructions:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/0/b0ba726fd823269d30d17c048f35a16e8ca5f18d.png)

When I copy the generated " **.jar**" file to "Ignition\lib\core\common"...  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/e/dee5b88a887d4b2afdf0d41e254f2274595afdba.png)

...the " **MQTT Engine**" module stops working because this **error** occurs:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/0/805a2eea609be4f0de4c139c6ca899acd1cc96fc.png)

There seems to be a dependency conflict.

Any help please?

Best Regards.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 23, 2023, 2:42pm UTC](https://forum.inductiveautomation.com/t/java-lang-classnotfoundexception-org-eclipse-paho-client-mqttv3-mqttcallbackextended/80853/2 "2023-10-23T14:42:13Z")

</div>

The MQTT modules use Tahu internally (their own copy) and you have overridden with a likely-incompatible version.

You have three choices:

- Java classloader trickery to access Cirrus Link's packaged tahu, or

- Package your jar in a module so it gets its own isolated classloader, then expose selected classes/methods with Ignition's ScriptManager infrastructure, or

- Create a simple module that **depends** on an MQTT module, then expose selected classes/methods from the Cirrus Link tahu with Ignition's ScriptManager infrastructure.

(None of those are trivial, sorry. Start with Ignition's SDK examples.)

---

<div class="post-metadata">

**Author:** ![AlbertAG](https://avatars.discourse-cdn.com/v4/letter/a/8797f3/32.png) [@AlbertAG](https://forum.inductiveautomation.com/u/AlbertAG)\
**Post date:** [October 24, 2023, 7:42am UTC](https://forum.inductiveautomation.com/t/java-lang-classnotfoundexception-org-eclipse-paho-client-mqttv3-mqttcallbackextended/80853/3 "2023-10-24T07:42:46Z")

</div>

Thanks for the response.

Regarding the first option, what does "Java classloader trickery" mean? Do you mean this object: [ClassLoader (Java Platform SE 8 )](https://docs.oracle.com/javase/8/docs/api/java/lang/ClassLoader.html)? Is there any example or documentation of how to access a class packaged inside a module (".modl")?

Best regards.

---

<div class="post-metadata">

**Author:** ![thidalgo](https://avatars.discourse-cdn.com/v4/letter/t/898d66/32.png) [@thidalgo](https://forum.inductiveautomation.com/u/thidalgo)\
**Post date:** [November 5, 2023, 5:26pm UTC](https://forum.inductiveautomation.com/t/java-lang-classnotfoundexception-org-eclipse-paho-client-mqttv3-mqttcallbackextended/80853/4 "2023-11-05T17:26:27Z")

</div>

Hi,

MQTT Engine Module contains Tahu.Core.1.0.5.jar and Tahu.Host.1.0.5.jar

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/c/4c23e378ddd14238e10a247e4eccdbc53c45bf2c.png)

Both export their main classes, look at their manifest:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/1/6189e91a6a9732f6efeecb2200439d7d7a233319.png)

So, really this classes should be used from gateways scripts.

I've taken the simple example from Tahu:

> <https://github.com/eclipse/tahu/blob/master/java/examples/simple/src/main/java/org/eclipse/tahu/SparkplugExample.java>

And I've succesfully imported all the classes used by the example in a script of the project library. Look as the execution on the Script Console does not return any error after impoting all the classes used by the example.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/d/6d1b3820ccd0f6a80ae5e8be6e4744d5b5b2f98a.png)

Try to tanslate the rest of the java example to jython, I think it should work.

Kind Regards. 🙂

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [November 6, 2023, 2:21am UTC](https://forum.inductiveautomation.com/t/java-lang-classnotfoundexception-org-eclipse-paho-client-mqttv3-mqttcallbackextended/80853/5 "2023-11-06T02:21:36Z")

</div>

> [@thidalgo](#):
>
> So, really this classes should be used from gateways scripts.

No, in the Gateway, modules are loaded in their own isolated ClassLoader. Scripting does not have access to the JARs used by modules in Gateway scope.

It works in the Designer console because Cirrus Link is also loading these JARs in Client/Designer scope, and in Client/Designer scope there is no module ClassLoader hierarchy like in the Gateway.

---

<div class="post-metadata">

**Author:** ![thidalgo](https://avatars.discourse-cdn.com/v4/letter/t/898d66/32.png) [@thidalgo](https://forum.inductiveautomation.com/u/thidalgo)\
**Post date:** [November 8, 2023, 12:04pm UTC](https://forum.inductiveautomation.com/t/java-lang-classnotfoundexception-org-eclipse-paho-client-mqttv3-mqttcallbackextended/80853/6 "2023-11-08T12:04:11Z")

</div>

You are right.

So, recovering the comment from "pturmel" (Java classloader trickery to access Cirrus Link's packaged tahu ...).Do you think It's possible to work in the gateway scope trough the Cirrus Gateway Module Hook ? How could I obtain information of the classes exposed by the Cirrus Gateway Module Hook?

Thanks.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 8, 2023, 1:40pm UTC](https://forum.inductiveautomation.com/t/java-lang-classnotfoundexception-org-eclipse-paho-client-mqttv3-mqttcallbackextended/80853/7 "2023-11-08T13:40:15Z")

</div>

Given a gateway context or module context in gateway scope (such as provided by `system.util.toolkitCtx()` in my `Integration Toolkit`), you can uses its `.getModule()` method to obtain the hook class instance. That class will have a dedicated module classloader that is responsible for the module's jars. You can ask that classloader to load classes by name for you. Once you have a class loaded into a name in a jython interpreter, it behaves just like an imported class.

---

<div class="post-metadata">

**Author:** ![thidalgo](https://avatars.discourse-cdn.com/v4/letter/t/898d66/32.png) [@thidalgo](https://forum.inductiveautomation.com/u/thidalgo)\
**Post date:** [November 9, 2023, 12:22am UTC](https://forum.inductiveautomation.com/t/java-lang-classnotfoundexception-org-eclipse-paho-client-mqttv3-mqttcallbackextended/80853/8 "2023-11-09T00:22:53Z")

</div>

Awesome,

It will take a time to implement a working example, but, by the moment I could instantiate a SparkplugB Payload Builder:

```auto
hook = system.util.toolkitCtx().getModule('com.cirruslink.mqtt.engine.gateway').getClass()
cloader = java.lang.Class.getClassLoader(hook)
_SparkplugBPayload = cloader.loadClass('org.eclipse.tahu.message.model.SparkplugBPayload')
deathPayload = _SparkplugBPayload.SparkplugBPayloadBuilder()

```

Many Thanks.
