Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest serialization library doesn't work #21

Open
kentosi opened this issue Aug 16, 2022 · 2 comments
Open

Latest serialization library doesn't work #21

kentosi opened this issue Aug 16, 2022 · 2 comments

Comments

@kentosi
Copy link

kentosi commented Aug 16, 2022

I downloaded the latest version of this code and it fails when attempting the following as per the tutorial:

curl -X POST http://localhost:9090/shoppingList \
   -H 'Content-Type: application/json' \
   -d '{
  "desc": "Peppers 🌶",
  "priority": 5
}'

The error I receive is:

2022-08-15 22:27:46.237 [DefaultDispatcher-worker-1] INFO  ktor.application - Responding at http://0.0.0.0:9090
2022-08-15 22:27:48.945 [eventLoopGroupProxy-4-1] ERROR ktor.application - Unhandled: POST - /shoppingList
java.lang.VerifyError: class kotlinx.serialization.json.internal.StreamingJsonDecoder overrides final method kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableElement(Lkotlinx/serialization/descriptors/SerialDescriptor;ILkotlinx/serialization/DeserializationStrategy;Ljava/lang/Object;)Ljava/lang/Object;
	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
	at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
	at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:800)
	at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:698)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:621)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:579)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
	at kotlinx.serialization.json.Json.decodeFromString(Json.kt:99)
	at io.ktor.serialization.kotlinx.KotlinxSerializationConverter.deserialize(KotlinxSerializationConverter.kt:55)
	at io.ktor.server.plugins.contentnegotiation.RequestConverterKt$convertRequestBody$1$1.invokeSuspend(RequestConverter.kt:38)
	at io.ktor.server.plugins.contentnegotiation.RequestConverterKt$convertRequestBody$1$1.invoke(RequestConverter.kt)
...

After spending a while looking through this error, it turns out that the fix is to revert this line in build.gradle.kts from this:

val serializationVersion = "1.3.3"

To this:

val serializationVersion = "1.3.2"

After doing this, the application works.

@mmacphail
Copy link

I had the same issue, and I solved it thanks to you ! I tried using the 1.4.0, but it still did not work.

@sebastinto
Copy link

1.4.0 is working for me after updating other dependencies:

val kotlinVersion = "1.7.20-RC"
val serializationVersion = "1.4.0"
val ktorVersion = "2.1.1"
val logbackVersion = "1.4.1"
val kotlinWrappersVersion = "1.0.0-pre.386"
val kmongoVersion = "4.7.1"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants