I am coding a spring application. I have a scheduled job like this.
@Async
@Scheduled(cron = "0 0 16 * * ?")
public void createReport()
{
// argJasperPath = /WEB-INF/jasperFiles/myreport.jasper
JasperPrint jasperPrint = JasperFillManager.fillReport(argJasperPath, argReportParams, argDataSource);
JasperExportManager.exportReportToPdfFile(jasperPrint, argOutputPath);
}
This runs at 16:00 every day and create a report. I am using JasperReports for generating reports. I have myreport.jasper file under /WEB-INF/jasperFiles/myreport.jasper, when I run my job while generating report I get FileNotFound exception.
How can I reach my jasper files in my scheduled method?
If we autowire
ServletContextwe can reach directory like this:(context.getRealPath(argJasperPath)