https://kotlinlang.org logo
#ktor
Title
# ktor
m

Manas Marthi

02/22/2024, 10:55 PM
Any thoughts on this error
ClassNotFoundException: org.jetbrains.kotlin.name.ClassId
I was making basic changes to a login form and the POST handler is failing when I try to call
call.respondRedirecT("/")
I added map<String, Any> to UserSession class. Session serialization does not like Any. It sassy no serialiser found. Annotate Any with ‘@Contextual’ . Not sure what it means
a

Aleksei Tirman [JB]

02/23/2024, 8:33 AM
The error occurs because the
Any
type doesn't have a serializer defined at the compile-time. You can read about the contextual serialization in the documentation of the kotlinx.serialization framework. Have you resolved the problem with the
ClassNotFoundException
?
m

Manas Marthi

02/24/2024, 9:09 PM
Session serialization does not work when I use LocalDate members. I had to add
@Contexualize
annotation. I tried to use KTORM orm instead of Exposed ORM. That also seems to have caused error. I had to convert KTORM instances into a
@Serializable
data class object. Serialization fails when any object is of type
Any
. So trying to store a
Map<String,Any>
bombs out.
It finally worked after I removed all
Any
properties and made the above mentioned changes
KTORM ORM uses interfaces to define entity objects. So I can't add
@Serialziable
@Contextual annotations
. KTOR Sessions and KTORM entity objects don't work with each other as of now. Probably I will find a way forward when I am more familiar with Kotlin type system
Not sure why it got sent to the channel