Java - Jasper

   
Vista:

Jasper

Publicado por JP (1 intervención) el 11/11/2011 16:07:47
Señores
Por favor su ayuda...

Tengo el siguiente metodo, el cual instancia a un archivo .jasper para la creacion de un excel final.


--------------------------------------------------------------------------------------------------

public Informe getIReport(String archivo, String pais){
Informe informe = new Informe();
BaseDatos bd = new BaseDatos(pais);
bd.ConexionBD();
Consulta consulta = null;
consultaService = new ConsultaService(new ConsultaDAO());
consulta = consultaService.getConsulta(archivo, pais);
try {
System.out.println(consulta);
JasperPrint jrPrint;
FileInputStream fileJasper = null;
fileJasper = new FileInputStream("C:\\Usuario\\VtaAcumuladaFACL.jasper");
JasperReport masterReport= null;

try {
masterReport= (JasperReport) JRLoader.loadObject(fileJasper);
} catch (JRException err) {
System.out.println("Error cargando archivo .jasper: " + err.getMessage());
System.exit(1);
}

jrPrint=JasperFillManager.fillReport (masterReport, null, bd.getConexion());
JExcelApiExporter exporter2 = new JExcelApiExporter();
exporter2.setParameter(JExcelApiExporterParameter.JASPER_PRINT,jrPrint);
exporter2.setParameter(JExcelApiExporterParameter.OUTPUT_STREAM,new FileOutputStream(archivo + consulta.getExt()));
exporter2.setParameter(JExcelApiExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);
exporter2.setParameter(JExcelApiExporterParameter.IS_COLLAPSE_ROW_SPAN, Boolean.TRUE);
exporter2.setParameter(JExcelApiExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS , Boolean.TRUE);
exporter2.setParameter(JExcelApiExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS , Boolean.TRUE);
exporter2.setParameter(JExcelApiExporterParameter.IS_WHITE_PAGE_BACKGROUND , Boolean.FALSE);
exporter2.exportReport();

} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}

File file = new File(archivo + consulta.getExt());
try {
File filezip = new File(archivo + ".zip");
ZipOutputStream zip = new ZipOutputStream((OutputStream)new FileOutputStream(filezip.getName()));

zip.setLevel(9);
FileInputStream is = new FileInputStream(archivo + consulta.getExt());
ZipEntry zipEntry = new ZipEntry(file.getName());

zip.putNextEntry(zipEntry);

System.out.println("Se incorpora " + archivo + consulta.getExt() + " a: " + filezip.getName());

byte[] buffer = new byte[1024];
int byteCount;
while (-1 != (byteCount = is.read(buffer))) {
zip.write(buffer, 0, byteCount);
}
zip.closeEntry();
is.close();
zip.close();

informe.setNombreArchivo(archivo + ".zip");
System.out.println("PATH: " + filezip.getPath());

informe.setBytes(getBytesFromFile(filezip));
System.out.println("VtaAcumulada .ZIP: " + filezip.getName());

if(filezip.delete() && file.delete()){
System.out.println("Se elimino el archivo ["+ archivo + consulta.getExt()+ " - " + archivo + ".zip ]");
}else{
System.out.println("NO se elimino el archivo ["+ archivo + consulta.getExt()+ " - " + archivo + ".zip ]");
}
} catch (IOException e) {
System.out.println("Error Nuevo");
e.printStackTrace();
}
return informe;
}

--------------------------------------------------------------------------------------------------


TODO BIEN, hasta que esto lo exporto a un archivo .JAR para su ejecucion de forma diaria.

Me entrega la siguiente excepcion:


--------------------------------------------------------------------------------------------------

java.io.IOException: Stream closed
at java.io.BufferedInputStream.getInIfOpen(BufferedInputStream.java:134)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
at java.io.DataInputStream.readUnsignedShort(DataInputStream.java:320)
at java.io.DataInputStream.readUTF(DataInputStream.java:572)
at java.io.DataInputStream.readUTF(DataInputStream.java:547)
at org.codehaus.groovy.reflection.GeneratedMetaMethod$DgmMethodRecord.loadDgmInfo(GeneratedMetaMethod.java:173)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.registerMethods(MetaClassRegistryImpl.java:139)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:81)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:59)
at groovy.lang.GroovySystem.<clinit>(GroovySystem.java:29)
at org.codehaus.groovy.runtime.InvokerHelper.<clinit>(InvokerHelper.java:49)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.initMetaClass(ScriptBytecodeAdapter.java:782)
at VtaAcumuladaFACL_1320953161765_518038.$getStaticMetaClass(calculator_VtaAcumuladaFACL_1320953161765_518038)
at VtaAcumuladaFACL_1320953161765_518038.<init>(calculator_VtaAcumuladaFACL_1320953161765_518038:18)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at net.sf.jasperreports.engine.design.JRAbstractJavaCompiler.loadEvaluator(JRAbstractJavaCompiler.java:98)
at net.sf.jasperreports.engine.design.JRAbstractCompiler.loadEvaluator(JRAbstractCompiler.java:320)
at net.sf.jasperreports.engine.JasperCompileManager.loadEvaluator(JasperCompileManager.java:237)
at net.sf.jasperreports.engine.fill.JRFillDataset.createCalculator(JRFillDataset.java:427)
at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:363)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:77)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:87)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:57)
at net.sf.jasperreports.engine.fill.JRFiller.createFiller(JRFiller.java:142)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:52)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:417)
at cl.falabella.DAP.aslplus.dao.InformeDAO.getIReport(InformeDAO.java:164)
at cl.falabella.DAP.aslplus.service.InformeService.getIReport(InformeService.java:17)
at cl.falabella.DAP.aslplus.dao.MailDAO.getMail(MailDAO.java:56)
at cl.falabella.DAP.aslplus.service.MailService.getMail(MailService.java:14)
at cl.falabella.DAP.aslplus.main.Principal.ejecuta(Principal.java:42)
at cl.falabella.DAP.aslplus.main.Principal.main(Principal.java:29)
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.codehaus.groovy.runtime.InvokerHelper.<clinit>(InvokerHelper.java:49)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.initMetaClass(ScriptBytecodeAdapter.java:782)
at VtaAcumuladaFACL_1320953161765_518038.$getStaticMetaClass(calculator_VtaAcumuladaFACL_1320953161765_518038)
at VtaAcumuladaFACL_1320953161765_518038.<init>(calculator_VtaAcumuladaFACL_1320953161765_518038:18)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at net.sf.jasperreports.engine.design.JRAbstractJavaCompiler.loadEvaluator(JRAbstractJavaCompiler.java:98)
at net.sf.jasperreports.engine.design.JRAbstractCompiler.loadEvaluator(JRAbstractCompiler.java:320)
at net.sf.jasperreports.engine.JasperCompileManager.loadEvaluator(JasperCompileManager.java:237)
at net.sf.jasperreports.engine.fill.JRFillDataset.createCalculator(JRFillDataset.java:427)
at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:363)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:77)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:87)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:57)
at net.sf.jasperreports.engine.fill.JRFiller.createFiller(JRFiller.java:142)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:52)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:417)
at cl.falabella.DAP.aslplus.dao.InformeDAO.getIReport(InformeDAO.java:164)
at cl.falabella.DAP.aslplus.service.InformeService.getIReport(InformeService.java:17)
at cl.falabella.DAP.aslplus.dao.MailDAO.getMail(MailDAO.java:56)
at cl.falabella.DAP.aslplus.service.MailService.getMail(MailService.java:14)
at cl.falabella.DAP.aslplus.main.Principal.ejecuta(Principal.java:42)
at cl.falabella.DAP.aslplus.main.Principal.main(Principal.java:29)
Caused by: groovy.lang.GroovyRuntimeException: Failed to register the DGM methods : java.io.IOException: Stream closed
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.registerMethods(MetaClassRegistryImpl.java:163)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:81)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:59)
at groovy.lang.GroovySystem.<clinit>(GroovySystem.java:29)
... 27 more
Caused by: java.io.IOException: Stream closed
at java.io.BufferedInputStream.getInIfOpen(BufferedInputStream.java:134)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
at java.io.DataInputStream.readUnsignedShort(DataInputStream.java:320)
at java.io.DataInputStream.readUTF(DataInputStream.java:572)
at java.io.DataInputStream.readUTF(DataInputStream.java:547)
at org.codehaus.groovy.reflection.GeneratedMetaMethod$DgmMethodRecord.loadDgmInfo(GeneratedMetaMethod.java:173)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.registerMethods(MetaClassRegistryImpl.java:139)
... 30 more

--------------------------------------------------------------------------------------------------


Algún antecedente del porqué ocurre esto... GRACIAS!
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder