Keep on getting a `NoSuchMethodError` when running...
# coroutines
n
Keep on getting a
NoSuchMethodError
when running a program that uses a Kotlin library I have developed called KMQTT Client ( https://gitlab.com/napperley/kmqtt-client ), which uses coroutines. The error occurs when invoking the
publish
function. Below is the function's definition ( https://gitlab.com/napperley/kmqtt-client/blob/master/src/jvmMain/kotlin/org/digieng/kmqtt/client/MqttClient.kt#L37 ) in the library:
Copy code
actual suspend fun publish(topic: String, msg: MqttMessage, timeout: Long): MqttError? = try {
        client.publish(topic, PahoMqttMessage(msg.payload.toByteArray()))
        null
    } catch (mqttPersistenceEx: MqttPersistenceException) {
        MqttError(mqttPersistenceEx.message ?: "Message persistence failed.", MqttStatus.MSG_PERSISTENCE_FAILED)
    } catch (mqttEx: MqttException) {
        MqttError(mqttEx.message ?: "Message delivery failed.", MqttStatus.MSG_DELIVERY_FAILED)
    }
Below are some of the error details:
Copy code
Exception in thread "main" java.lang.NoSuchMethodError: 'java.lang.Object org.digieng.kmqtt.client.MqttClient.publish$default(org.digieng.kmqtt.client.MqttClient, java.lang.String, org.digieng.kmqtt.client.MqttMessage, long, kotlin.coroutines.Continuation, int, java.lang.Object)'
Surprised that the
NoSuchMethodError
didn't appear earlier when invoking the
connect
function ( https://gitlab.com/napperley/kmqtt-client/blob/master/src/jvmMain/kotlin/org/digieng/kmqtt/client/MqttClient.kt#L88 ).