How Do You Run An Akka HTTP Server?

I followed this tutorial, and here is the github for the tutorial’s code. The tutorial doesn’t mention any main method, so I assume there is a perhaps a way to run it with the object Server extends App object. How do you run the server as the main function or is there another way to run this code? Thank you for any help, it is very much appreciated.

Yes, that’s the intended way to run it, with the Server object here

It’s an SBT project, so you would use > run at the SBT > prompt I think. That should automatically pick up the main method; if there is more than one main, then SBT lets you choose.

1 Like

Thank you for the help. I got it run as a sbt task but it says:
insecure HTTP request is unsupported 'http://repo.typesafe.com/typesafe/releases'; switch to HTTPS or opt-in as ("typesafe-releases" at "http://repo.typesafe.com/typesafe/releases").withAllowInsecureProtocol(true), or by using allowInsecureProtocol in repositories file

Well the tutorial is 5 years old, some stuff is outdated :smiley:

I think the Typesafe repo might not exist, or might have changed addresses. Because Typesafe became Lightbend. Or maybe it still works :person_shrugging:

The error seems to be coming from resolvers in build.sbt. You can try changing it to https to see if it helps.

Now after that, I think the bintray repo also changed at some point… I get a 404 from that address. You can try by simply commenting out the resolvers entirely to see if it helps.

Otherwise you’ll have to update the dependencies yourself. Look them up on Scaladex but make sure you get the right language version.

1 Like

Thank you for the help

I think I might be wrong; looking at the repo’s README you are supposed to use Docker instead… but I’m not sure if that would work either. (I don’t have Docker)

I’ve been trying to modify build.sbt and project/build.properties to make it compile but I think my JVM is too new for this project (21), can’t get it to work.
One thing that did work was changing akkaPersistenceInmemoryVersion to "2.5.15.2".

1 Like

I was able to fix the Sbt build.
Here is my fork.
Tested with Java 21
Screenshot from 2024-08-08 13-02-03

2 Likes

Thank you so much

1 Like

Hey sorry I didn’t get a chance to run it yet as I have been busy the last couple of days. Did you run it with sbt or docker by any chance?

No Docker, just SBT.

1 Like