I'm creating a class using deltaspike and quartz, using @scheduled. In this Injection class a CDI bean, which is a class of service. I chose to use deltaspike because it controls the context of the CDI within classes that use quartz. The bean, however, is not injected, being null. No exception is thrown on the console. The code does not appear or be called. But removing all the code from the method, removing @Inject and leaving only the log calls, works perfectly. What might be missing configure for dependency injection to work? Follow the code below.
@Scheduled(cronExpression = "0 0/1 * * * ?")
public class NotificacaoAgendaJob implements Job {
Logger logger = Logger.getLogger("br.com.nutrierp.scheduler");
@Inject
AgendaService agendaService;
public void execute(JobExecutionContext context) throws JobExecutionException {
try {
logger.info("Iniciando Job...");
List<Agenda> agendas = agendaService.todasAgendasDoSistema();
for (Agenda agenda : agendas) {
LocalDateTime dataAgendada = agenda.getDataInicial();
LocalDateTime dataAtual = LocalDateTime.now();
Duration intervalo = Duration.between(dataAtual, dataAgendada);
if (intervalo.toHours() <= 24 && intervalo.toHours() > 0) {
agendaService.enviarEmailDeNotificacao(agenda);
}
}
logger.info("Finalizando Job...");
} catch (Exception e) {
e.printStackTrace();
}
}
}