playframework - Play 2.4 - using Ebean in eager singleton module -
i have got question.
i using play framework ebean. trying port application play 2.4 , trying use dependency injection technique introduced in play.
in previous version using globalsettings.onstart() initialize things after application starts (cron-like service). in 2.4 trying implement "onstart" process eagerly loaded singleton using dependency injection framework.
generally speaking, working. however, sometimes, getting nullpointerexception while starting application. stack trace, can assume, exception happening while accessing database (ebeanserver null in time). assumed, ebean has not started because eager singletons initiliased before application starts. ok then, injected play`s application , database objects eager singleton constructor in order start in time.
the results ... unstable. sometime application starts fine, sometime falls in same nullpointerexception.
looks database not started in time or what? or maybe need inject other ebean object in order start database?
ok figured out.
i had inject play.db.ebean.ebeanconfig
, play.api.db.evolutions.dynamicevolutions
, ebean starting earlier dependency of eager singleton.
these exact 2 classes, injected while loading play-ebean plugin can see here https://github.com/playframework/play-ebean/blob/master/play-ebean/src/main/java/play/db/ebean/ebeanmodule.java
Comments
Post a Comment