I have got a question.
I am using Play Framework with Ebean. I am trying to port my application to Play 2.4 and I am trying to use dependency injection technique introduced in Play.
In previous version I was using GlobalSettings.onStart() to initialize some things after the application starts (cron-like service). In 2.4 I am trying to implement "onStart" process as eagerly loaded singleton using dependency injection framework.
Generally speaking, it is working. However, sometimes, I am getting NullPointerException while starting application. From stack trace, I can assume, that the exception is happening while accessing database (EbeanServer is null in that time). So I assumed, that Ebean has not properly started because eager singletons are initiliased before application starts. OK then, I injected Play`s Application and Database objects into the eager singleton constructor in order to start everything up in time.
The results are ... unstable. Sometime application starts fine, sometime it falls in the same NullPointerException.
Looks like the database is sometimes not started in time or what? Or maybe I need to inject some other Ebean object in order to start database?