Hi, tried to make small service with Ktor and Ampe...
# amper
v
Hi, tried to make small service with Ktor and Amper as build tool. I auto-generated project from intellij... App runs from IDE but I'm trying now to create dockerfile.... and found that it cannot run from terminal. So if I do:
./gradlew build --no-daemon
and then:
java -jar build/libs/app-jvm.jar
I will get:
Copy code
Error: Could not find or load main class io.ktor.server.netty.EngineMain
Caused by: java.lang.ClassNotFoundException: io.ktor.server.netty.EngineMain
Now .... I tried with relative path to Application.kt, still does not work EDIT: I've tried with new generated project from Ktor, it's the same, you cannot start jar from build/libs
j
Hi! Can you please confirm that you're using Gradle-based Amper here? (the Amper plugin in Gradle, not the standalone Amper build tool)
Now to your problem, it looks like this is not specific to Amper. If you run
./gradlew build
(even without Amper), it will just build a jar containing your own classes. It is not a self-contained fat jar with all dependencies. You would need to pass all dependency jars on the classpath in your
java
call. Usually people either use some 3rd party Gradle plugin to create a fat jar, or the built-in Gradle Distribution plugin to create an application distribution. The distribution is a zip or directory containing
lib/
with all jars, and
bin/
with a couple start scripts that use the correct java command to run your application.
1
Since this is not very convenient, we will make this simpler in Amper, but this distribution mechanism / format is not implemented yet.
👍 1