-
Notifications
You must be signed in to change notification settings - Fork 172
Open
Labels
Description
🐛 Bug Report
Unable to connect with running any «Distributable» task in Intellij IDEA like runDistributable
. I also tried to install the app using an .msi
package and ran it – the result was the same.
Everything works with the run
or runRelease
tasks.
🔬 How To Reproduce
Steps to reproduce the behavior:
- Create new project in Intellij IDEA: Compose for Desktop
- Add lib implementation, insert Reproducer code
- Run
runDistributable
Gradle task - Try to connect by click on the button
Reproducer code
@Composable
fun App() {
var client: Mqtt5AsyncClient = Mqtt5Client
.builder()
.buildAsync()
Button(onClick = {
client
.connect() // <- invokes «Caused by: java.lang.ClassNotFoundException: sun.misc.Unsafe»
}) {
Text("onClick")
}
}
fun main() = application {
Window(onCloseRequest = ::exitApplication) {
App()
}
}
It doesn't matter which broker you want to connect. Whether it's async or not, the version of Mqtt and the SDK are not important too.
The log when the application starts:
Aug 23, 2024 10:08:02 AM io.netty.util.internal.PlatformDependent <clinit>
INFO: Your platform does not provide complete low-level API for accessing direct buffers reliably. Unless explicitly requested, heap buffer will always be preferred to avoid potential system instability.
The log after on the button click:
Aug 23, 2024 10:08:02 AM io.netty.util.internal.PlatformDependent <clinit>
INFO: Your platform does not provide complete low-level API for accessing direct buffers reliably. Unless explicitly requested, heap buffer will always be preferred to avoid potential system instability.
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: sun/misc/Unsafe
at org.jctools.util.UnsafeAccess.<clinit>(UnsafeAccess.java:46)
at org.jctools.queues.BaseSpscLinkedArrayQueueConsumerField.<clinit>(BaseSpscLinkedArrayQueue.java:47)
at com.hivemq.client.internal.mqtt.handler.publish.outgoing.MqttOutgoingQosHandler.<init>(MqttOutgoingQosHandler.java:92)
at com.hivemq.client.internal.mqtt.handler.publish.outgoing.MqttOutgoingQosHandler_Factory.newInstance(MqttOutgoingQosHandler_Factory.java:34)
at com.hivemq.client.internal.mqtt.handler.publish.outgoing.MqttOutgoingQosHandler_Factory.get(MqttOutgoingQosHandler_Factory.java:25)
at com.hivemq.client.internal.mqtt.handler.publish.outgoing.MqttOutgoingQosHandler_Factory.get(MqttOutgoingQosHandler_Factory.java:8)
at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
at com.hivemq.client.internal.mqtt.handler.MqttSession_Factory.get(MqttSession_Factory.java:35)
at com.hivemq.client.internal.mqtt.handler.MqttSession_Factory.get(MqttSession_Factory.java:10)
at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
at com.hivemq.client.internal.mqtt.handler.connect.MqttConnectHandler_Factory.get(MqttConnectHandler_Factory.java:43)
at com.hivemq.client.internal.mqtt.handler.connect.MqttConnectHandler_Factory.get(MqttConnectHandler_Factory.java:11)
at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
at com.hivemq.client.internal.mqtt.handler.MqttChannelInitializer_Factory.get(MqttChannelInitializer_Factory.java:60)
at com.hivemq.client.internal.mqtt.handler.MqttChannelInitializer_Factory.get(MqttChannelInitializer_Factory.java:17)
at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
at com.hivemq.client.internal.mqtt.ioc.DaggerSingletonComponent$ClientComponentImpl$ConnectionComponentImpl.bootstrap(DaggerSingletonComponent.java:440)
at com.hivemq.client.internal.mqtt.handler.connect.MqttConnAckSingle.connect(MqttConnAckSingle.java:86)
at com.hivemq.client.internal.mqtt.handler.connect.MqttConnAckSingle.subscribeActual(MqttConnAckSingle.java:68)
at io.reactivex.Single.subscribe(Single.java:3666)
at io.reactivex.internal.operators.single.SingleObserveOn.subscribeActual(SingleObserveOn.java:35)
at io.reactivex.Single.subscribe(Single.java:3666)
at com.hivemq.client.internal.rx.RxFutureConverter$RxSingleFuture.<init>(RxFutureConverter.java:113)
at com.hivemq.client.internal.rx.RxFutureConverter.toFuture(RxFutureConverter.java:43)
at com.hivemq.client.internal.mqtt.MqttAsyncClient.connect(MqttAsyncClient.java:116)
at com.hivemq.client.internal.mqtt.MqttAsyncClient.connect(MqttAsyncClient.java:109)
at MainKt$App$1.invoke$lambda$0(Main.kt:21)
at androidx.compose.foundation.ClickablePointerInputNode$pointerInput$3.invoke-k-4lQ0M(Clickable.kt:991)
at androidx.compose.foundation.ClickablePointerInputNode$pointerInput$3.invoke(Clickable.kt:984)
at androidx.compose.foundation.gestures.TapGestureDetectorKt$detectTapAndPress$2$1.invokeSuspend(TapGestureDetector.kt:258)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:175)
at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:164)
at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:470)
at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl(CancellableContinuationImpl.kt:504)
at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default(CancellableContinuationImpl.kt:493)
at kotlinx.coroutines.CancellableContinuationImpl.resumeWith(CancellableContinuationImpl.kt:364)
at androidx.compose.ui.input.pointer.SuspendingPointerInputModifierNodeImpl$PointerEventHandlerCoroutine.offerPointerEvent(SuspendingPointerInputFilter.kt:672)
at androidx.compose.ui.input.pointer.SuspendingPointerInputModifierNodeImpl.dispatchPointerEvent(SuspendingPointerInputFilter.kt:549)
at androidx.compose.ui.input.pointer.SuspendingPointerInputModifierNodeImpl.onPointerEvent-H0pRuoY(SuspendingPointerInputFilter.kt:571)
at androidx.compose.foundation.AbstractClickablePointerInputNode.onPointerEvent-H0pRuoY(Clickable.kt:950)
at androidx.compose.foundation.AbstractClickableNode.onPointerEvent-H0pRuoY(Clickable.kt:798)
at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:326)
at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:312)
at androidx.compose.ui.input.pointer.NodeParent.dispatchMainEventPass(HitPathTracker.kt:187)
at androidx.compose.ui.input.pointer.HitPathTracker.dispatchChanges(HitPathTracker.kt:106)
at androidx.compose.ui.input.pointer.PointerInputEventProcessor.process-BIzXfog(PointerInputEventProcessor.kt:114)
at androidx.compose.ui.node.RootNodeOwner.onPointerInput(RootNodeOwner.skiko.kt:212)
at androidx.compose.ui.scene.MultiLayerComposeSceneImpl.processRelease(MultiLayerComposeScene.skiko.kt:321)
at androidx.compose.ui.scene.MultiLayerComposeSceneImpl.processPointerInputEvent(MultiLayerComposeScene.skiko.kt:236)
at androidx.compose.ui.scene.BaseComposeScene$inputHandler$2.invoke(BaseComposeScene.skiko.kt:62)
at androidx.compose.ui.scene.BaseComposeScene$inputHandler$2.invoke(BaseComposeScene.skiko.kt:62)
at androidx.compose.ui.input.pointer.SyntheticEventSender.sendInternal(SyntheticEventSender.skiko.kt:175)
at androidx.compose.ui.input.pointer.SyntheticEventSender.send(SyntheticEventSender.skiko.kt:79)
at androidx.compose.ui.scene.ComposeSceneInputHandler.onPointerEvent-WlEVilQ(ComposeSceneInputHandler.skiko.kt:123)
at androidx.compose.ui.scene.ComposeSceneInputHandler.onPointerEvent-BGSDPeU(ComposeSceneInputHandler.skiko.kt:89)
at androidx.compose.ui.scene.BaseComposeScene.sendPointerEvent-BGSDPeU(BaseComposeScene.skiko.kt:185)
at androidx.compose.ui.scene.ComposeScene.sendPointerEvent-BGSDPeU$default(ComposeScene.skiko.kt:186)
at androidx.compose.ui.scene.ComposeSceneMediator_desktopKt.onMouseEvent-d-4ec7I(ComposeSceneMediator.desktop.kt:709)
at androidx.compose.ui.scene.ComposeSceneMediator_desktopKt.access$onMouseEvent-d-4ec7I(ComposeSceneMediator.desktop.kt:1)
at androidx.compose.ui.scene.ComposeSceneMediator.onMouseEvent(ComposeSceneMediator.desktop.kt:403)
at androidx.compose.ui.scene.ComposeSceneMediator.access$onMouseEvent(ComposeSceneMediator.desktop.kt:102)
at androidx.compose.ui.scene.ComposeSceneMediator$mouseListener$1.mouseReleased(ComposeSceneMediator.desktop.kt:234)
at java.desktop/java.awt.Component.processMouseEvent(Unknown Source)
at java.desktop/java.awt.Component.processEvent(Unknown Source)
at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Unknown Source)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Unknown Source)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.ui.scene.ComposeContainer$DesktopCoroutineExceptionHandler@291adba, androidx.compose.runtime.BroadcastFrameClock@145d1a76, StandaloneCoroutine{Cancelling}@7870b26d, FlushCoroutineDispatcher@27da7131]
Caused by: java.lang.ClassNotFoundException: sun.misc.Unsafe
Caused by: java.lang.ClassNotFoundException: sun.misc.Unsafe
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
... 84 more
Then you can start run
task and see that nothing crashes.
Perhaps I'm doing something wrong, or maybe the library itself isn't designed for desktop use.
Context
Windows 10 1809
Intellij IDEA 2024.2.0.1
hivemq-mqtt-client version: 1.3.3
kotlin version: 2.0.10
compose version: 1.6.11