Hello everyone. Anyone could help me with a serial...
# ktor
Hello everyone. Anyone could help me with a serialization error. I’ve set up an Exposed user in ktor 2:
Copy code
object Users: IntIdTable() {
    val username = varchar("username", 128)
    val email = varchar("email", 128)
    val password = varchar("password", 1024)

class User(id: EntityID<Int>, username: String, email: String, password: String): IntEntity(id) {
    companion object : IntEntityClass<User>(Users)
    var username by Users.username
    var email by Users.email
    var password by Users.password
my serialization plugin is :
Copy code
import io.ktor.serialization.kotlinx.json.*
import io.ktor.server.plugins.*
import io.ktor.server.application.*

fun Application.configureSerialization() {
    install(ContentNegotiation) {
when I call, I get
Copy code
500: kotlinx.serialization.SerializationException: Serializer for class 'User' is not found.
Mark the class as @Serializable or provide the serializer explicitly.
If I try adding @Serializable above the class User, my ide says
Copy code
This class does not have a constructor
Cannot access 'Serializable': it is internal in '<http://kotlin.io|kotlin.io>'
You can view my project on this branch: https://github.com/danygiguere/ktor-kotlin-example/tree/setting-up-exposed
wrong serializable,
thanks @ephemient Does it mean I need to replace a depedency or does it have to do with my serialization plugin ?
no, it means you need to import that one and not
when you write
the IDE's auto-import functionality can get confused by multiple names sometimes so don't rely on it, check
I’m getting this ide error now though:
Impossible to make this class serializable because its parent is not serializable and does not have exactly one constructor without parameters
that's a #serialization question but will depend on your class structure. every property should be a
, https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/basic-serialization.md#constructor-properties-requirement
thanks @ephemient I’ll try to figure it out, else I’ll bring the question to the serialization channel
I don’t think you can properly serialize/deserialize entity class so you need a separate serializable
@thanks @Aleksei Tirman [JB] I’ve created a Ca model to simplify things and I’ll bring the question to the serialization channel.