Problem with JRLoader

1

I am trying to run a report in Jasper Report with the following code:

Class.forName("org.postgresql.Driver");
Connection conexion = DriverManager.getConnection("jdbc:postgresql://localhost:5432/reportes", usuario, contraseña;
File reportDir=new File(getServletContext().getRealPath("WEB-INF/repProd.jasper"));
JasperReport reporte= (JasperReport) JRLoader.loadObject(reportDir);
JasperPrint jasperPrint = JasperFillManager.fillReport(reporte, null, conexion);
JRExporter exporter = new JRPdfExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, out);//new java.io.File("reportePDF.pdf")
exporter.exportReport();

However, it generates an error in the line:

JasperReport reporte= (JasperReport) JRLoader.loadObject(reportDir);

The error is as follows:

  

The Servlet.service () for the servlet [SrvRepProd] in the context with   route [/ Application] launched the exception [Execution of Servlet launched   an exception] with root cause java.lang.ClassNotFoundException:   org.apache.commons.logging.LogFactory

Any ideas?

    
asked by Leo T 24.01.2017 в 22:57
source

1 answer

3

You need the Apache Commons Logging library and add it to your classpath. You can find her here

    
answered by 25.01.2017 / 18:34
source