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

Kotless with kotlinx.serialization fails #107

Open
laithdhawahir opened this issue Jun 16, 2021 · 3 comments
Open

Kotless with kotlinx.serialization fails #107

laithdhawahir opened this issue Jun 16, 2021 · 3 comments

Comments

@laithdhawahir
Copy link

laithdhawahir commented Jun 16, 2021

Hi all,
I have this gradle code.


plugins {
    kotlin("jvm") version "1.5.10"

    // Json serialization
    kotlin("plugin.serialization") version "1.5.10"

    // kotless
    id("io.kotless") version "0.1.6"
}

group = "com.dhawahir.trade.collector"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()
    jcenter()

    maven {
        url = uri("https://jitpack.io")
    }
}

dependencies {
    testImplementation(kotlin("test"))

    // kotless
    implementation("io.kotless", "kotless-lang", "0.1.6")

    // Json serialization
    implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.2.1")
}

tasks.test {
    useJUnitPlatform()
}

tasks.withType<KotlinCompile>() {
    kotlinOptions.jvmTarget = "11"
}

When I run this, I get the following error


Your current kotlinx.serialization core version is too low, while current Kotlin compiler plugin 1.5.10 requires at least 1.0-M1-SNAPSHOT. Please update your kotlinx.serialization runtime dependency.

when I do gradle dependencies I see this

+--- io.kotless:kotless-lang:0.1.6
|    \--- io.kotless:lang-common:0.1.6
|         +--- io.kotless:model:0.1.6
|         |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.72 -> 1.5.10 (*)
|         +--- org.slf4j:slf4j-api:1.7.30
|         +--- com.amazonaws:aws-java-sdk-core:1.11.788
|         |    +--- commons-logging:commons-logging:1.1.3 -> 1.2
|         |    +--- org.apache.httpcomponents:httpclient:4.5.9
|         |    |    +--- org.apache.httpcomponents:httpcore:4.4.11
|         |    |    +--- commons-logging:commons-logging:1.2
|         |    |    \--- commons-codec:commons-codec:1.11
|         |    +--- software.amazon.ion:ion-java:1.0.2
|         |    +--- com.fasterxml.jackson.core:jackson-databind:2.6.7.3 -> 2.10.4
|         |    |    +--- com.fasterxml.jackson.core:jackson-annotations:2.10.4
|         |    |    \--- com.fasterxml.jackson.core:jackson-core:2.10.4
|         |    +--- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:2.6.7
|         |    |    \--- com.fasterxml.jackson.core:jackson-core:2.6.7 -> 2.10.4
|         |    \--- joda-time:joda-time:2.8.1
|         +--- org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.20.0
|         |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.70 -> 1.5.10 (*)
|         |    \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.70 -> 1.5.10
|         \--- com.amazonaws:aws-lambda-java-core:1.2.0

Which I suspect the issue is in org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.20.0 , I am using the right version of kotless can I resolve this issue in gradle ?

@laithdhawahir
Copy link
Author

laithdhawahir commented Jun 16, 2021

Solved the issue with the following code added to the dependency block

    // Resolve Conflicts
    modules {

        // Resolve conflict between kotless and kotlinx-serialization
        module("org.jetbrains.kotlinx:kotlinx-serialization-runtime") {
            replacedBy(
                "org.jetbrains.kotlinx:kotlinx-serialization-json",
                "kotless is using obsolete version of kotlinx.serialization"
            )
        }
    }

@laithdhawahir
Copy link
Author

laithdhawahir commented Jun 16, 2021

My previous solution solved the build failure but caused this exception in runtime.

java.lang.NoClassDefFoundError: Could not initialize class io.kotless.dsl.utils.Json
	at io.kotless.local.handler.DynamicHandler.handle(DynamicHandler.kt:46)
	at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:59)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
	at org.eclipse.jetty.server.Server.handle(Server.java:501)
	at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:383)
	at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:556)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:375)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:273)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
	at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129)
	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:375)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:806)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:938)
	at java.base/java.lang.Thread.run(Thread.java:832)

@TanVD
Copy link
Member

TanVD commented Jun 17, 2021

Consider for now using 1.4.* version and use Kotless 0.1.7 :)

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

2 participants