Jasreport unknow error

hi, I’m new to your platform and I just uploaded my Spring Boot project, I have a problem with a function that takes care of creating PDF with Jasreport, idk if i had to add an parameter because i use this method in another sever (CentOS7) but in Railway it doesn´t work
8 Replies
Percy
Percy2y ago
Project ID: 49a649e6-18bd-49d5-8ff9-229140c455cb
.matinc
.matincOP2y ago
49a649e6-18bd-49d5-8ff9-229140c455cb project id
Brody
Brody2y ago
what parameter did you add and where did you add it, provide as much detail as you can please
.matinc
.matincOP2y ago
public void crearRuta(Long id) throws FileNotFoundException { String carpetaRelativa = "Boletin/Curso/"; String rutaCarpeta = carpetaRelativa + cursoRepositorio.findById(id).get().getCurso() + "" + cursoRepositorio.findById(id).get().getDivision() + "" + reemplazarEspacios(cursoRepositorio.findById(id).get().getOrientacion()) + "_" + cursoRepositorio.findById(id).get().getTurno(); String rutaAbsoluta = servletContext.getRealPath(rutaCarpeta); crearCarpeta(rutaAbsoluta); }. This is the controller that creates the path for the folder where I want the pdf reports to be saved (if it's not already created) public void crearCarpeta(String ruta) { File carpeta = new File(ruta); if (!carpeta.exists()) { if (carpeta.mkdirs()) { System.out.println("Carpeta creada correctamente en: " + carpeta.getAbsolutePath()); } else { System.out.println("Error al crear la carpeta."); } } else { System.out.println("La carpeta ya existe en: " + carpeta.getAbsolutePath()); } }. This is the function that receives the url and creates the folder if everything goes well
.matinc
.matincOP2y ago
@PostMapping("/export-pdf") public String exportPdf(@RequestParam("cursoId") Long cursoId, @RequestParam("alumnoIds") List<Long> alumnoIds) throws JRException, FileNotFoundException, SQLException { crearRuta(cursoId); for (Long a : alumnoIds) { Connection connection = null; // Declarar la conexión fuera del bloque try-catch try { connection = dataSource.getConnection(); Map<String, Object> params = new HashMap<>(); params.put("p_ciclo_lectivo", 2023); params.put("p_curso", cursoId.intValue()); params.put("palumno", a.intValue()); String reportName = servletContext.getRealPath("/resources/BoletinCalificaciones.jrxml"); String carpetaRelativa = "Boletin/Curso/"; String rutaCarpeta = carpetaRelativa + cursoRepositorio.findById(cursoId).get().getCurso() + "" + cursoRepositorio.findById(cursoId).get().getDivision() + "" + reemplazarEspacios(cursoRepositorio.findById(cursoId).get().getOrientacion()) + "" + cursoRepositorio.findById(cursoId).get().getTurno() + "/bol_" + alumnoRepositorio.findById(a).get().getDni() + ".pdf"; String rutaAbsoluta = servletContext.getRealPath(rutaCarpeta); BoletinReportGenerator.exportToPdf(connection, reportName, rutaAbsoluta, params); } catch (SQLException e) { System.out.println(e.getMessage()); } finally { if (connection != null) { try { connection.close(); } catch (SQLException e) { System.out.println("Error al cerrar la conexión: " + e.getMessage()); } } } } return "redirect:/boletin/curso-boletin?id=" + cursoId; }.
.matinc
.matincOP2y ago
Finally this is the controller that creates the pdf files in the url.
Brody
Brody2y ago
that's a lot of Spanish? that I can't read lol I also can't read java, so that probably doesn't help either
.matinc
.matincOP2y ago
sorry xd, I'm Argentinean
Want results from more Discord servers?
Add your server