DEV Community

Discussion on: Publishing server-side Kotlin applications: Ktor on Heroku

 
andresantospt profile image
André L. Santos

I forgot to mention that when generating a project like in your tutorial, it goes fine. my difference is that i'm doing the multi-platform Kotlin/KotlinJs

Thread Thread
 
sebastianaigner profile image
Sebastian Aigner • Edited

Thanks for sharing the project. I investigated this by running installDist locally, which creates a "start script" in /build/install/qlciscte/bin – and that indeed throws a IllegalArgumentException: Neither port nor sslPort specified.

And in fact, you're actually hitting a bug here! More specifically, KT-37964 Gradle application/distribution plugin does not copy and name jar files correctly when using installDist task for multiplatform project.

The TLDR: installDist generates a script with an entry point using your projects .jar, which the isn't properly being copied. The workaround:

distributions {
    main {
        contents {
            from("$buildDir/libs") {
                rename("${rootProject.name}-jvm", rootProject.name)
                into("lib")
            }
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

Hope this will be fixed in due time. Tripped me up as well, as you can see :)

You can also find a working Gradle configuration in the companion project for the "Building a Full Stack Web App with Kotlin Multiplatform" hands-on tutorial.

Thread Thread
 
andresantospt profile image
André L. Santos

now it works when I run the binary produced by gradle stage. however, when uploading to Heroku, the app still crashes. Here's the log entry:
2021-01-28T11:18:09.671617+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=qlciscte.herokuapp.com request_id=fbea81df-588f-443f-a520-7072d3110169 fwd="94.63.156.9" dyno= connect= service= status=503 bytes= protocol=https

It's not very informative. Do you know any trick to get a more detailed trace of what went wrong on Heroku?

Thread Thread
 
sebastianaigner profile image
Sebastian Aigner

Discovered the issue by running heroku logs --tail before actually triggering a build. That gave me:

2021-01-28T12:13:20.330000+00:00 app[web.1]: bash: build/install/untitled/bin/untitled: No such file or directory
Enter fullscreen mode Exit fullscreen mode

You might want to adjust the contents of your Procfile, since your project is no longer called untitled 😉

Thread Thread
 
andresantospt profile image
André L. Santos

meanwhile I also noticed that :) now I have another problem, but that has to with class version compilation of some libs i'm using.
thanks for the tip!