Dependency injection in Akka Actor


I’m using an Actor inside a Play 2.8 application, how do Inject the JPAApi jpaApi inside an actor? If I use the field annotation with @Inject I get a nullpointer.

The actor is a child of another actor, the first one in the hierarchy gets created automatically at application start, so I cannot pass the JPAApi from parent to children (and I also think is not a best practice to do it). I need the JPAApi only in this actor, because is the only one that does some operations on the Db.

My actor, looks like this:

package actors;

import models.DatabaseExecutionContext;
import models.jpaRepository.GameRepository;
import play.db.jpa.JPAApi;
import service.GameService;

import javax.inject.Inject;

public class GameSimulator extends AbstractLoggingActor {

    private int period;
    private final String gameId;
    private JPAApi jpaApi;
    private DatabaseExecutionContext databaseExecutionContext;
    private final GameService gameService;
    private final GameRepository gameRepository;

    private GameSimulator(String gameId) {
        this.period = 1;
        this.gameId = gameId;
        this.gameService = new GameService(jpaApi, databaseExecutionContext);
        this.gameRepository = new GameRepository(jpaApi, databaseExecutionContext);

    public static Props props(final String gameId){
        return Props.create(GameSimulator.class, () -> new GameSimulator(gameId));

    public Receive createReceive() {
        return emptyBehavior();

If you can provide me some info of something to read about it I would be very glad, thanks!

Found and Implemented this, and seems to work fine: