What state management framework should I use with Jewel? (Compose)

I’ve tried using both Molecule and Koin for state management, but I’m running into class loader errors with both of them. Does anyone know how to fix this?


java.lang.ClassCastException: class androidx.compose.runtime.ComposerImpl cannot be cast to class androidx.compose.runtime.Composer (androidx.compose.runtime.ComposerImpl is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @5d06915d; androidx.compose.runtime.Composer is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @4adf6740)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jb.kt:33)
	at org.jetbrains.jewel.bridge.ToolWindowExtensionsKt.addComposeTab$lambda$0(ToolWindowExtensions.kt:26)


Here’s my configuration:

dependencies {

    implementation("ai.koog:koog-agents:0.3.0"){
        exclude(group = "org.jetbrains.compose")
        exclude(group = "androidx.compose")
        exclude(group = "androidx.compose.runtime")
        exclude(group = "androidx.compose.ui")
        exclude(group = "androidx.compose.foundation")
        exclude(group = "androidx.compose.material")
    }
    testImplementation("junit:junit:4.13.2")
    testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.2")
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2")
    implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.0")
    implementation("app.cash.molecule:molecule-runtime:${molecule_version}"){
        exclude(group = "org.jetbrains.compose.material")
    }

    intellijPlatform {
        create("IC", "2025.2")
        testFramework(TestFrameworkType.Platform)
        bundledModule("intellij.platform.jewel.foundation")
        bundledModule("intellij.platform.jewel.ui")
        bundledModule("intellij.platform.jewel.ideLafBridge")
        bundledModule("intellij.platform.jewel.markdown.core")
        bundledModule("intellij.platform.jewel.markdown.ideLafBridgeStyling")
        bundledModule("intellij.libraries.compose.foundation.desktop")
        bundledModule("intellij.libraries.skiko")
    }
}

Hey, most probably

jetbrains.compose.runtime.desktop

loaded somewhere twice and you have to exclude it as well.

Please take a look on our examples of plugin development with Compose intellij-platform-compose-plugin-template/src/main/kotlin/org/jetbrains/plugins/template/weatherApp/ui/WeatherAppViewModel.kt at main · JetBrains/intellij-platform-compose-plugin-template · GitHub . This approach doesn’t require additional libraries.

1 Like

I’m not intimately familiar with the dependencies tree used of Molecule and Koin, but you very much want to make sure they are not bringing in Compose as a transitive dependency. Only the one from the platform should end up on the classpath if you want to avoid classloading issues.

The same goes for coroutines, and possibly kotlinx-serialization — I think they should already be on the classpath from the platform, or at least can be brought in from it.

Thank you, this example is helpful to me.