Answer the question
In order to leave comments, you need to log in
How to specify the relative path to the report file in JasperReport?
Good day to all.
Please tell me how to correctly specify the relative path to the report template file in JasperReports.
Now I've encountered a problem that while I'm working with an unpackaged program (I'm running it from ide), the report is being generated.
However, when I build the project, it throws java.io.FileNotFoundException.
The report file gets into Jar during assembly. However, apparently it cannot access the running archive itself.
I form the path to the report file like this
StringBuilder constructReportPlace = new StringBuilder();
constructReportPlace.append(runPath);
constructReportPlace.append("/src/main/resources/reports/Report.jasper");
Answer the question
In order to leave comments, you need to log in
there are several spsb -
1. regarding the project
System.err.println(
String.format("%s/src/main/resources/%s",
System.getProperty("user.dir"), resourceFileName));
System.err.println(
String.format("The running application resource path: \"%s\"",
Thread.currentThread().getContextClassLoader()
.getResource("").getPath()));
this.getClass().getClassLoader()
.getResourceAsStream(
I'm probably doing something wrong, but it doesn't work.
String reportPlace = String.format("\"%sreports/Task.jasper",
Thread.currentThread().getContextClassLoader()
.getResource("").getPath());
InputStream std = new FileInputStream(reportPlace);
JasperReport jasperReport = (JasperReport) JRLoader.loadObject(std);
"status": 500,
"error": "Internal Server Error",
"message": " \"file:\\D:\\Java\\Spriп\\target\\Tot.jar!\\BOOT-INF\\classes!\\reports\\Task.jasper (Синтаксическая ошибка в имени файла, имени папки или метке тома)",
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question