NoClassDefFoundError when using Exposed
Asked Answered
N

1

5

I'm using Exposed as my database library and I'm getting these errors when I try to run my code:

Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/reflect/full/KClasses
    at org.jetbrains.exposed.sql.Table.clone(Table.kt:196)
    at org.jetbrains.exposed.sql.Table.cloneWithAutoInc(Table.kt:234)
    at org.jetbrains.exposed.sql.Table.autoIncrement(Table.kt:238)
    at org.jetbrains.exposed.sql.Table.autoIncrement$default(Table.kt:238)
    at vanilla.jubeatbook.data.Songs.<init>(SQLObjects.kt:14)
    at vanilla.jubeatbook.data.Songs.<clinit>(SQLObjects.kt:13)
    at vanilla.jubeatbook.backend.MainKt$main$1.invoke(Main.kt:22)
    at vanilla.jubeatbook.backend.MainKt$main$1.invoke(Main.kt)
    at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.inTopLevelTransaction(ThreadLocalTransactionManager.kt:70)
    at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction(ThreadLocalTransactionManager.kt:58)
    at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction(ThreadLocalTransactionManager.kt:49)
    at vanilla.jubeatbook.backend.MainKt.main(Main.kt:21)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.lang.ClassNotFoundException: kotlin.reflect.full.KClasses
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 17 more

Code snippet for SQLObjects.kt:

object Songs : Table() {
    val _id = integer("_id").autoIncrement().primaryKey() // Line 14
    val songId = integer("song_id")
    val title = text("title")
    val artist = text("artist")
    val levelBSC = integer("level_bsc")
    val levelADV = integer("level_adv")
    val levelEXT = integer("level_ext")
}

I think I followed the sample code right but I can't just figure out what throws these.

Nazarite answered 13/6, 2017 at 15:55 Comment(1)
Thanks for posting the question, I just realized that all the code I've written with the JDBC library was basically unnecessary..Farinose
K
11

You need to add kotlin-reflect as a dependency to your project.

Kana answered 13/6, 2017 at 16:59 Comment(2)
I have the same problem that occur sometimes, but I have already added <code>kotlin-reflect</code> dependency in my project. Do you know anything else? Thanks.Sabelle
it will help if you added the implementation line implementation(kotlin("reflect"))Smalley

© 2022 - 2024 — McMap. All rights reserved.