Flaxoos/extra-ktor-plugins

`ktor-server-kafka` default configuration crashing app

Opened this issue · 2 comments

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)

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

  • ktor (version 2.3.11 to 2.3.2
  • coroutines (version 1.8.1 to 1.7.1)
  • logback (version 1.5.6 to 1.4.11)

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

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