JRLoader.loadObject error of JasperReport

3

I'm new to this jasper report , I do not know if I'm missing something or why I get this error:

My Code line with error:

JasperReport reporte = (JasperReport) 
JRLoader.loadObject("ReporteComisiones.jasper");

It's a maven project, with respect to jasperreport I only have this dependency

<dependency>
            <groupId>net.sf.jasperreports</groupId>
            <artifactId>jasperreports</artifactId>
            <version>6.3.0</version>
        </dependency>

the error in the line of code is

  

no suitable method found for loadObject (String)

Thanks for the help.

    
asked by Henrry José Portilla Paredes 23.11.2018 в 21:44
source

1 answer

0

The error that is giving you is that you are sending a String when you wait for the full path of the report.

So what you can do is send the name of the report to a function that finds the complete path where you have your report, like this example:

  private InputStream reportFile(String file) {
        return ((ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext())
.getResourceAsStream("/resources/reports/" + file);
    }

Here you already call the report as you have it in your code

JasperReport MasterReport = (JasperReport) 
JRLoader.loadObject(reportFile("ReporteComisiones.jasper"));
  

Note: "/ resources / reports /" this route may vary depending on where you have your report folder

    
answered by 23.11.2018 / 22:17
source