0
I have a JSF project, I use Netbeans.
This function generates a Jasper report and was working normal, but after compiling the project started to release the exception util.loader.object.from.input.stream.loading.error
The problem is on this line: JasperReport report = (JasperReport) JRLoader.loadObject(stream);
The problem is not the location of . Jasper or the subreport, since I saw it debugging that the stream is loaded.
the function code:
public void reciboMensal(CobMensal cob, Date data, String user) throws FileNotFoundException {
stream = this.getClass().getClassLoader().getResourceAsStream("ReciboGrp.jasper");
Map<String, Object> params = new HashMap<String, Object>();
baos = new ByteArrayOutputStream();
try{
params.put("idben", cob.getBen().getId());
params.put("data", data);
params.put("usuario", user);
JasperReport report = (JasperReport) JRLoader.loadObject(stream);
JasperPrint print = JasperFillManager.fillReport(report, params, getConexao());
JasperExportManager.exportReportToPdfStream(print, baos);
response.reset();
response.setContentType("application/pdf");
response.setContentLength(baos.size());
response.setHeader("Content-disposition", "inline; filename=recibo.pdf");
response.getOutputStream().write(baos.toByteArray());
response.getOutputStream().flush();
response.getOutputStream().close();
context.responseComplete();
fecharConexao();
}catch (JRException | IOException ex) {
Logger.getLogger(Relatorio.class.getName()).log(Level.SEVERE, null, ex);
}
}
Caused da stack
Caused by: java.io.StreamCorruptedException: invalid stream header: EFBFBDEF
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:866)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:358)
at net.sf.jasperreports.engine.util.ContextClassLoaderObjectInputStream.<init>(ContextClassLoaderObjectInputStream.java:56)
at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:277)
at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:262)
at br.soames.report.Relatorio.reciboMensal(Relatorio.java:62)
Can help?