2

I have a Java web project in the Jboss 7 in which I use Jasper reports. I modified the layout of jasper file tested on localhost this all right. I deploy the server but it still carries the jasper file to the previous layout. Jasper has not updated at all. Already cleaned the folders in tmp folder, I stopped and started the server, changed the way in which was saved jasper and nothing works.

public class UtilRelatorios {

public static void imprimeRelatorio(String relatorioNome,
        HashMap parametros) throws IOException, JRException {
        FacesContext fc = FacesContext.getCurrentInstance();
        ServletContext context = (ServletContext) fc.getExternalContext().getContext();
        HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
        JasperPrint jasperPrint = 
                JasperFillManager.fillReport(
                        context.getRealPath("/relatorios/jasper")+ File.separator+relatorioNome+".jasper",
                        parametros);     
        byte[] b = null;

        try {
            b = JasperExportManager.exportReportToPdf(jasperPrint);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
        }    

            if (b != null && b.length > 0) {
                // Envia o relatório em formato PDF para o browser
                response.setContentType("application/pdf");
                int codigo = (int) (Math.random()*1000);
                response.setHeader("Content-disposition","inline);filename=relatorio_"+codigo+".pdf");
                response.setContentLength(b.length);
                ServletOutputStream ouputStream = response.getOutputStream();
                ouputStream.write(b, 0, b.length);
                ouputStream.flush();
                ouputStream.close();
            }   
 }

}

csf
  • 189
  • 1
  • 3
  • 13

1 Answers1

2

.jrxml and .jasper

You have surely edited your .jrxml, but have you complied it with success to a new .jasper (the complied version)

and is it the .jasper file that you have updated?

Note: in your code you are not compiling the .jrxml but using directly the complied version .jasper, so you need to overwrite this.

how-do-i-compile-jrxml-to-get-jasper

what-is-the-difference-between-jasperreport-formats

If this does not work, output the context.getRealPath("/relatorios/jasper")+ File.separator+relatorioNome+".jasper" to understand which file you need to replace.

Community
  • 1
  • 1
Petter Friberg
  • 21,252
  • 9
  • 60
  • 109
  • I compile the .jrxml using iReport and put the .jasper updated on the project. Now to test compiled using JasperCompileManager localhost and everything worked out, but the server still carries the old .jasper. I do not know what might be happening because I've done changes before and there was never this problem. – csf Nov 30 '15 at 12:24
  • You are simple not overwriting the correct .jasper file with a new .jasper file ... there is no other reason (check last date modified ecc.)... If you don't have some other code that overwrites the .jasper file... – Petter Friberg Nov 30 '15 at 12:29
  • Petter I saved in the project file already compiled .jasper I just substitute it in the folder. I have tested compiling .jrxml via code with JasperCompileManager and remains the error. I have also changed the way the .jasper and the error remains. – csf Nov 30 '15 at 17:11
  • This seems very strange, browser that cache the response? – Petter Friberg Dec 01 '15 at 08:06
  • I figured out my problem components were adjustable to the size of the texts in Jasper layout. Localhost in the texts apereciam normally, but being the first server in the texts were cut. I left the major components that the texts and it worked. – csf Dec 01 '15 at 13:28