I found a way to make it work. It seems the problem was with the annotations. My EJB programmatic timer was not executing even if I changed it to a really simple case.
I used the annotation @Singleton instead of @Stateless (both can't be used) and @Startup like this:
@Singleton
@Startup
public class ExpirationWatch {
@Resource
private TimerService timerService;
@Inject
@ConfigProperty(name = "app.cronExpiredDepartures", defaultValue = "* * * * *")
private String cronExpression;
@PostConstruct
public void init() {
ScheduleExpression schedule = new ScheduleExpression();
String[] parts = cronExpression.split(" ");
schedule
.second("0")
.minute(parts[0])
.hour(parts[1])
.dayOfMonth(parts[2])
.month(parts[3])
.dayOfWeek(parts[4]);
timerService.createCalendarTimer(schedule, new TimerConfig("ExpirationWatchTimer", false));
}
@Timeout
@Transactional
public void checkExpiredDepartures() {
System.out.println("checkExpiredDepartures executed");
}
}
}