g

    Guilherme Delgado

    1 week ago
    Hi! Anyone trying to make a network call in jvm target (desktopApp) and getting:
    Exception in thread “main” java.lang.NoClassDefFoundError: java/net/http/HttpClient$Version
    It crashes when I try to provide
    ktor.HttpClient
    have no idea why 🤷‍♂️ (my DI setup is similar to other online samples, ex PeopleInSpace). I even tried something simpler like:
    actual fun platformModule() = module {
        single<HttpClient> { HttpClient(Java.create()) }
    }
    
    object HelperTest : KoinComponent {
        val httpClient = get<HttpClient>()
    }
    
    LaunchedEffect(Unit) {
        DependencyInjection.initKoin()
        println("${HelperTest.httpClient}") // BOOOM!
    }
    Thanks.
    Found it: https://github.com/JetBrains/compose-jb/blob/master/tutorials/Native_distributions_and_local_execution/README.md#configuring-included-jdk-modules and thanks to @Andreas Scheja for suggesting
    modules("<http://java.net|java.net>.http")