getting error to deploy ktor project on heroku

198 Views Asked by At

Hello Developers I am student and I'm working on Ktor project.I want to deploy my collage project on heroku.But I stuck in Ktor Project deployment Help me how to solve it. I'll provide my error log

This is my Error log

    2022-08-10T23:27:30.774776+00:00 heroku[web.1]: State changed from crashed to starting
2022-08-10T23:27:33.495899+00:00 heroku[web.1]: Starting process with command `build/install/example/bin/example`
2022-08-10T23:27:34.411007+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2022-08-10T23:27:34.411144+00:00 app[web.1]: bash: build/install/example/bin/example: No such file or directory
2022-08-10T23:27:34.564150+00:00 heroku[web.1]: Process exited with status 127
2022-08-10T23:27:34.839969+00:00 heroku[web.1]: State changed from starting to crashed
2022-08-10T23:27:55.000000+00:00 app[api]: Build succeeded
2022-08-10T23:28:16.724424+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=mighty-savannah-19369.herokuapp.com request_id=c5e35266-6ef5-4a42-9dac-6a894f06b4df fwd="109.249.187.28" dyno= connect= service= status=503 bytes= protocol=https
2022-08-10T23:28:16.999875+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=mighty-savannah-19369.herokuapp.com request_id=d29c073f-e8ce-45f3-b8cd-5b5a9099577f fwd="109.249.187.28" dyno= connect= service= status=503 bytes= protocol=https
2022-08-10T23:32:50.106331+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/robots.txt" host=mighty-savannah-19369.herokuapp.com request_id=a848f7f9-62d0-4063-a207-cb01fd01ec40 fwd="66.249.66.92" dyno= connect= service= status=503 bytes= protocol=http
2022-08-10T23:32:50.954114+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=mighty-savannah-19369.herokuapp.com request_id=4abc4eba-d021-491b-82b4-8525e0fe6905 fwd="46.40.5.5" dyno= connect= service= status=503 bytes= protocol=http
2022-08-10T23:32:51.587762+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=mighty-savannah-19369.herokuapp.com request_id=765cf552-f168-48b9-aa03-8b76d97eb635 fwd="170.84.132.5" dyno= connect= service= status=503 bytes= protocol=http

Here is my Build.gradle file

val ktor_version: String by project
val kotlin_version: String by project
val logback_version: String by project
val exposed_version: String by project
val postgres_version: String by project
val hikari_version: String by project


plugins {
    application
    kotlin("jvm") version "1.7.0"
}

group = "com.example"
version = "0.0.1"
application {
    mainClass.set("com.example.ApplicationKt")

    val isDevelopment: Boolean = project.ext.has("development")
    applicationDefaultJvmArgs = listOf("-Dio.ktor.development=$isDevelopment")
}

tasks.create("stage"){
    dependsOn("installDist")
}
repositories {
    mavenCentral()
    maven { url = uri("https://maven.pkg.jetbrains.space/public/p/ktor/eap") }
}

dependencies {
    implementation("io.ktor:ktor-server-content-negotiation-jvm:$ktor_version")
    implementation("io.ktor:ktor-server-core-jvm:$ktor_version")
    implementation("io.ktor:ktor-serialization-gson-jvm:$ktor_version")
    implementation("io.ktor:ktor-server-locations-jvm:$ktor_version")
    implementation("io.ktor:ktor-server-sessions-jvm:$ktor_version")
    implementation("io.ktor:ktor-server-auth-jvm:$ktor_version")
    implementation("io.ktor:ktor-server-auth-jwt-jvm:$ktor_version")
    implementation("io.ktor:ktor-server-netty-jvm:$ktor_version")
    implementation("ch.qos.logback:logback-classic:$logback_version")
    testImplementation("io.ktor:ktor-server-tests-jvm:$ktor_version")
    testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version")
    //DB Connection
    implementation("org.jetbrains.exposed:exposed-core:$exposed_version")
    implementation("org.jetbrains.exposed:exposed-dao:$exposed_version")
    implementation("org.jetbrains.exposed:exposed-jdbc:$exposed_version")
    implementation("org.postgresql:postgresql:$postgres_version")
    implementation("com.zaxxer:HikariCP:$hikari_version")
}

Please help me to solve this problem. also give me suggestion what am I doing wrong.

2

There are 2 best solutions below

0
Dtako On

This is a late answer, but I hope it helps. Flow from ktor document: https://ktor.io/docs/heroku.html#0 And make sure your app use Maximum JDK is JAVA_11. Cause the last JAVA which intellj support is JAVA_17 and maximum heroku support is java 11.

0
Nguyễn Kim Khánh On

Step1: create new file is system.properties in root project.
Step2: add: java.runtime.version=11 to the file in step 1. enter image description here ->> Done. Hope this help you.