I figured out the cause of the `DuplicateApplicati...
# ktor
t
I figured out the cause of the
DuplicateApplicationFeatureException
, I believe it's due to a bug in Ktor (sort of tracked here: https://youtrack.jetbrains.com/issue/KTOR-2586)
My app starts the server like so:
Copy code
embeddedServer(
        factory = Netty,
        port = 8080,
        host = "0.0.0.0",
        watchPaths = listOf("classes"),
        module = {
            val daggerAppComponent = DaggerAppComponent
                .builder()
                .logger(this.log)
                .build()

            install(CallLogging)
            install(CachingHeaders)
            artworkRouting(
                artworkService = daggerAppComponent.provideArtworkService(),
                databaseStorage = daggerAppComponent.provideDatabaseStorage(),
                imageProcessor = daggerAppComponent.provideImageProcessor(),
                awsClient = daggerAppComponent.provideAwsClient()
            )
        }
The
provideDatabaseStorage
actually throws an exception, due to the SQL Driver being unable to connect, because the application is not started yet. This exception is swallowed by Ktor, then the application tries to re-instantiate the modules, then fails because some of the modules are already installed. So, it turns out it's just an error in my code, that caused a misleading exception in Ktor