I am trying to create Jasper Report in Liferay portlet but I am getting below error:
Caused by: net.sf.jasperreports.engine.JRException: java.io.FileNotF
To help future users:
I see these problems
.jasper
, these .jasper
files are already compiled the command JasperCompileManager.compileReport
should be used to compile .jrxml
to .jasper
. For more information of jasper report file types see What is the difference between JasperReport formats?If you have you .jasper
inside of your package/distribution (src), the correct way to load the report would be using a class loader (hence src will change to bin).
InputStream jasperStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("com/ztscorp/lms/reports/HibernateQueryDemoReport.jasper");
JasperReport report = (JasperReport) JRLoader.loadObject(jasperStream);
If it outside of the distribution you can simple use File
with the relative or absolute path
JasperReport report = (JasperReport) JRLoader.loadObject(new File("jasperFolder/HibernateQueryDemoReport.jasper");