https://kotlinlang.org logo
#ktor
Title
# ktor
z

zsoltkiss

07/05/2019, 4:47 PM
Hi all! I'm new to Ktor and I'd need some help on how to generate a .war file from my Ktor webapp? Though I created a .war using Gretty plugin but the artifact has strange folder structure. I copied the .war on a Tomcat but can't see anything in the browser.
m

mp

07/05/2019, 5:36 PM
Not an answer to your immediate question, I know... but if you have the option of skipping tomcat & friends entirely and just starting ktor via a main method you'll probably be happier overall. Simpler local dev, more predictable production deployment.
z

zsoltkiss

07/08/2019, 9:32 AM
Hi Marshall, thanks for your help. You mean 'skipping' that I should not use Tomcat at all? It might be a solution, yes. Let me explain my original problem I have to solve... I built a Ktor web app and currently I run it from its .jar file using java command. But my customer needs a "public" images directory somewhere, where they will be able to put images into and the web app should reach these pictures. I don't know how to configure Ktor embedded server to see outside of its .jar file and reach images from an external directory... That's why I thought a standard web app directory structure on a Tomcat (or any web server) might be a solution. I don't stick to Tomcat at all if there is a solution to my problem using only Ktor and its embedded server.
m

mp

07/08/2019, 4:29 PM
I'd just provide a filesystem path via however you choose to do configuration, and pass that path to the static content feature: https://ktor.io/servers/features/static-content.html
easy peasy
I don't have static content in this demo but it does show how you can quite easily have a pretty sophisticated server stack with a
main()
function that you write (and therefore can set up any way you want): https://bitbucket.org/marshallpierce/ktor-demo/src/master/
z

zsoltkiss

07/09/2019, 8:19 PM
Very nice! Thanks a lot.
3 Views