I’ve spent a big chunk of the day trying to build a Java Lagom service with Maven, and run it independently without using any tooling.
I would like to get to the point where I can do the following and have a running service.
mvn package java -Dplay.server.http.port=9000 -D........other settings...... -jar service-impl/target/service-impl-1.0-SNAPSHOT.jar
This seems to be a strangely completely undocumented use case, and I’m still having trouble unpicking the ‘magic’ that the various layers of tooling do to make it work.
Among the (as far as I can see) undocumented issues I have experienced so far are:
The ApplicationLoader is described extensively in Scala but for Java services it seems to be “magic”. I still don’t think I understand how
play.application.loader should be set. Do I need to write a custom application loader?
Short of sitting comparing lists of jars one by one, it’s not clear which extra dependencies are necessary to make a service run outside of the dev tooling. Among others, I got dependency injection errors for:
ServiceRegistry(after binding an alternative
Service Locator registration / Play features
I don’t mind using the
ConfigurationServiceLocator but the approach described in the docs of injecting the Play
Environment to use
isProd doesn’t work, by default at least, and results in some extremely cryptic errors using the dev server. I lost a good hour or two working out that this was the cause of a
ClassCastException between Scala
Seq when running
So far, I’ve given up and gone back to using SBT and
sbt-native-packager. But I can’t believe I am the first or last person to want to do this, so it would be great if this thread could form a starting point for documenting this use case to save others the same journey