javascalafunctional-programmingsbtplayframework-2.6

Play framework: Why does https url not work on using "sbt dist" command?


I am trying to create executable file for deploying my web app using play framework sbt dist command. When I run my application using "sbt run" command then https work but when I use sbt dist and run my executable file to start my app then only http url works.

Following is my configuration

In build.sbt

javaOptions ++= Seq(
  "-Dhttps.keyStore=conf/keystore.jks",
  "-Dhttps.keyStorePassword=*****",
  "-Dhttp.port=9000",
  "-Dhttps.port=9001",
  "-Dsentry.dsn=https://****"
)

In application.conf

play.http {

  session {
    secure = true
    httpOnly = true
    domain = "localhost"
  }

  flash {
    secure = true
    httpOnly = true
  }
}

play.ws {
  ssl {
    trustManager = {
      stores = [
        { type = "JKS", path = "conf/keystore.jks" }
      ]
    }
  }
}


Solution

  • You need to define the javaOptions in Universal:

    javaOptions in Universal ++= Seq(
      "-Dhttps.keyStore=conf/keystore.jks",
      "-Dhttps.keyStorePassword=*****",
      "-Dhttp.port=9000",
      "-Dhttps.port=9001",
      "-Dsentry.dsn=https://****"
    )
    

    See https://www.scala-sbt.org/sbt-native-packager/archetypes/java_app/customize.html#via-build-sbt

    However, why not just define those settings in conf/application.conf?