每次我尝试在@Timeout 打开文件时,Java 都会返回空指针异常
@Singleton
public class EngineTrans {
@Resource
private TimerService timerService;
public void createProgrammaticalTimer() {
ScheduleExpression everyTenSeconds = new ScheduleExpression().second("*/15").minute("*").hour("4-20");
timerService.createCalendarTimer(everyTenSeconds, new TimerConfig(
"passed message " + new Date(), false));
}
@Timeout
public void handleTimer() {
System.out.println("timer received - contained message is: " + new Date());
File xmlFile = new File(FacesContext.getCurrentInstance().getExternalContext().getRealPath(""));
}
}
有任何想法吗?