kotlin-hands-on / jvm-js-fullstack

https://play.kotlinlang.org/hands-on/Full%20Stack%20Web%20App%20with%20Kotlin%20Multiplatform/
122 stars 149 forks source link

Error - Caused by : java.lang.NoSuchMethodError #10

Closed Gimzou closed 2 years ago

Gimzou commented 2 years ago

Hey there,

I've been trying to go through this hands on tutorial without success.

At step 3, when I try to POST a shoppingListElement, I end up with the following error (server stops running) :

Caused by: java.lang.NoSuchMethodError: java.nio.ByteBuffer.limit(I)Ljava/nio/ByteBuffer;

I get the same error at step 4, when trying to serve static content.

Any idea on how to solve this issue ?

mrbrianevans commented 2 years ago

I'm getting the same issue. I've tried checking out the final branch and get the same error:

Exception in thread "DefaultDispatcher-worker-1 @file-reader#4" java.lang.NoSuchMethodError: java.nio.ByteBuffer.limit(I)Ljava/nio/ByteBuffer;

Which version of Java/Kotlin should be set in IntelliJ for this project to work? I've tried a couple and none seem to fix this issue.

Gimzou commented 2 years ago

Hey Brian,

I managed to have a functional project (at least for the first 4 steps) with the following package versions :


// build.gradle.kts

...

val kotlinVersion = "1.6.10-RC"
val serializationVersion = "1.3.2"
val ktorVersion = "1.6.3"
val logbackVersion = "1.2.3"
val reactVersion = "17.0.2-pre.240-kotlin-1.5.30"
val kmongoVersion = "4.3.0"

plugins {
    kotlin("multiplatform") version "1.6.10-RC"
    application //to run JVM part
    kotlin("plugin.serialization") version "1.6.10-RC"
}

...

I don't know which package was causing the issue. I suspect there might be a conflict with the Serialization plugin.

Do these settings work for you too ?

mrbrianevans commented 2 years ago

Thank you. This solved the issue for me. The full application is working on my PC with those versions.

Gimzou commented 2 years ago

Proposed fix : #11

SebastianAigner commented 2 years ago

Thank you for reporting the issue and proposing a fix! I've merged your PR and updated the "final" branch to also reflect the change. 🎉