Robin Green
Robin Green

Reputation: 33083

Play Global object (GlobalSettings) not being executed

I ran my application successfully on a server, with a custom config file specified on the command line using:

-Dconfig.file=app.conf

but when I tried to copy the custom config file to my local machine and use it there, by passing -Dconfig.file to run, strange errors started to appear. I eventually traced this to my Global object's onStart method not being executed at all. Why is this happening?

Upvotes: 1

Views: 375

Answers (1)

Robin Green
Robin Green

Reputation: 33083

For some reason, the typesafe config library was silently failing to load this line in my custom config file

include "application"

but only from sbt run - it worked when running the application standalone on a server.

Therefore the application.global=global.Global line wasn't being read in that file, so Play couldn't find the Global object, and silently fell back to an empty Global object that does nothing.

Changing the include line to specify an absolute file path to application.conf fixed the problem.

Upvotes: 1

Related Questions