0

I found scala websocket example on github

I cloned this repo and made some small changes, I could get the server up running with sbt run command.

I packed this into a jar file with sbt package command, and tried to run with scala -classpath jarfilespath server.jar command, but with no luch

I tried adding all dependencies in the -classpath, but I still got error java.lang.NoSuchMethodError:com.typesafe.config.Config.getDuration

I also tried using sbt-assembly plugin, which generated a 20M+ jar file, but still it's giving the same error message

How do I pack this into a jar file and run with scala command? thanks!

jerry
  • 1,196
  • 2
  • 9
  • 21
  • 1
    You can have a look at https://github.com/geoHeil/akkaStreamsIngest, in general `sbt package`or `assembly` should be fine. Maybe you are excluding some dependencies in the assembly configuration. – Georg Heiler May 07 '17 at 16:46

1 Answers1

0

Indeed the result of sbt package will not work for you as this creates a jar with just the code from this project, not its dependencies.

You are correct that one solution would be to use the sbt-assembly plugin by adding to project/plugins.sbt:

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.4")

After this you can start the server with:

java -jar target/scala-2.11/websocket-akka-http-assembly-1.0.jar

Are you sure this gives you an error message? Which one exactly?

Arnout Engelen
  • 6,709
  • 1
  • 25
  • 36
  • thank you for your update, I found answer from [this post](http://stackoverflow.com/questions/24238060/how-to-run-jar-generated-by-package-possibly-with-other-jars-under-lib), it works for me – jerry May 16 '17 at 14:37