Securing communications in production mode

I’m trying to secure communications for a service with client authentication.

My service project’s definition is below:

lazy val fooImpl = (project in file("foo/foo-impl"))
  .settings(commonSettings: _*)
  .settings(lagomForkedTestSettings: _*)
    name := "foo-impl",
    version := Versions.FooImpl,
    libraryDependencies ++= Dependencies.fooImpl,
    javaAgents += "org.mortbay.jetty.alpn" % "jetty-alpn-agent" % "2.0.7" % "compile;test"
  .enablePlugins(LagomScala, PlayScala, PlayAkkaHttp2Support)
  .dependsOn(fooApi % "compile -> compile; test -> test")

When I stage this service and run

foo/foo-impl/target/universal/stage/bin/foo-impl -Dlagom.cluster.join-self=on -Dakka.remote.netty.tcp.port=0

I find that my application.conf is not found:

Oops, cannot start the server.
Configuration error: Configuration error[application: application.conf: resource not found on classpath: application.conf, application.json: resource not found on classpath: application.json, resource not found on classpath:]
	at play.api.Configuration$.configError(Configuration.scala:156)
	at play.api.Configuration$.load(Configuration.scala:102)
	at play.api.Configuration$.load(Configuration.scala:110)
	at play.api.ApplicationLoader$.createContext(ApplicationLoader.scala:113)
	at play.core.server.ProdServerStart$.start(ProdServerStart.scala:49)
	at play.core.server.ProdServerStart$.main(ProdServerStart.scala:25)
	at play.core.server.ProdServerStart.main(ProdServerStart.scala)

If I specify the config with -Dconfig.resource, I get the following exception:

Oops, cannot start the server.
java.lang.RuntimeException: No application loader is configured. Please configure an application loader either using the play.application.loader configuration property, or by depending on a module that configures one. You can add the Guice support module by adding "libraryDependencies += guice" to your build.sbt.

This is present in my application.conf (lest my application wouldn’t even run in development mode!).

I’ve tried without enabling PlayScala and I ran into the same problems.

Does this seem like a bug? Or am I making a mistake?

Hi @erip,

I think the problem is PlayHttp2Support transitively enables PlayLayoutPlugin so the sbt setup changes causing the resourcesDirectories to not include src/main/resources.

Long story short, disable PlayLayoutPlugin.

I think that transitive dependency between the plugins is a bug but that’s a question someone more familiar with the Play plugins may be able to answer. :sweat_smile:

BTW, I think Play’s plugin already adds the agent so, I think, you can remove the piece:

from your build.sbt.

It doesn’t, unfortunately. :(