Flaxoos / extra-ktor-plugins

Feature-rich, efficient, and highly customizable plugins for your Multiplatform Ktor Server or Client
https://flaxoos.github.io/extra-ktor-plugins/
Other
52 stars 2 forks source link

`ktor-server-kafka` default configuration crashing app #34

Open yonatankarp opened 2 weeks ago

yonatankarp commented 2 weeks ago

I have added the library to my project as follows:

dependencies {
   implementation("io.github.flaxoos:ktor-server-kafka:1.2.9")
}

and the following installation:


fun Application.module() {
    install(Kafka) {
        val topicName = named("xkcd.web-comics-fetched.v1")
        schemaRegistryUrl = "localhost:8081"
        topic(topicName) {
            partitions = 1
            replicas = 1
            configs {
                messageTimestampType = MessageTimestampType.CreateTime
            }
        }
        common {
            bootstrapServers =
                listOf(
                    "localhost:9092",
                )
            retries = 1
        }
        producer {
            clientId = "xkcddatahub-fetcher"
        }
        registerSchemas {
            WebComics::class at topicName
        }
    }
}

When running my app it crashes with the following error:

Exception in thread "main" java.lang.NoSuchMethodError: 'java.lang.ClassLoader ch.qos.logback.core.util.Loader.systemClassloaderIfNull(java.lang.ClassLoader)'
    at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:73)
    at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:66)
    at ch.qos.logback.classic.spi.LogbackServiceProvider.initializeLoggerContext(LogbackServiceProvider.java:52)
    at ch.qos.logback.classic.spi.LogbackServiceProvider.initialize(LogbackServiceProvider.java:41)
    at org.slf4j.LoggerFactory.bind(LoggerFactory.java:196)
    at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:183)
    at org.slf4j.LoggerFactory.getProvider(LoggerFactory.java:486)
    at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:472)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:421)
    at io.ktor.util.logging.KtorSimpleLoggerJvmKt.KtorSimpleLogger(KtorSimpleLoggerJvm.kt:10)
    at io.ktor.server.engine.CommandLineKt.buildCommandLineEnvironment(CommandLine.kt:35)
    at io.ktor.server.engine.CommandLineKt.commandLineEnvironment(CommandLine.kt:98)
    at io.ktor.server.netty.EngineMain.main(EngineMain.kt:20)
    at com.xkcddatahub.fetcher.bootstrap.ApplicationKt.main(Application.kt:15)
yonatankarp commented 2 weeks ago

@Flaxoos to solve this issue I had to change the following dependencies from the latest release:

Seems that to solve the issue, the library dependencies need to be updated.

yonatankarp commented 1 week ago

As agreed with @Flaxoos , we will add prefix version ranges for patch versions on all dependencies in the version catalog.