IDEMPIERE-2765 Error when running a Jasper reports via web services

This commit is contained in:
Diego Ruiz 2015-08-13 09:10:46 -05:00
parent 3c6e87f564
commit 3b78553e07
1 changed files with 7 additions and 36 deletions

View File

@ -11,21 +11,16 @@ import static org.compiere.model.SystemIDs.PROCESS_RPT_FINSTATEMENT;
import static org.compiere.model.SystemIDs.PROCESS_RPT_M_INOUT; import static org.compiere.model.SystemIDs.PROCESS_RPT_M_INOUT;
import static org.compiere.model.SystemIDs.PROCESS_RPT_M_INVENTORY; import static org.compiere.model.SystemIDs.PROCESS_RPT_M_INVENTORY;
import java.io.ByteArrayOutputStream;
import java.io.CharArrayWriter; import java.io.CharArrayWriter;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.ParseException; import java.text.ParseException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
import javax.xml.namespace.QName; import javax.xml.namespace.QName;
import net.sf.compilo.report.ReportProcessor;
import net.sf.jasperreports.engine.JasperPrint;
import org.adempiere.util.ProcessUtil; import org.adempiere.util.ProcessUtil;
import org.compiere.model.Lookup; import org.compiere.model.Lookup;
import org.compiere.model.MLookup; import org.compiere.model.MLookup;
@ -379,6 +374,7 @@ public class Process {
// Report // Report
if ((process.isReport() || jasperreport)) if ((process.isReport() || jasperreport))
{ {
pi.setReportingProcess(true);
r.setIsReport(true); r.setIsReport(true);
ReportEngine re=null; ReportEngine re=null;
if (!jasperreport) if (!jasperreport)
@ -418,11 +414,12 @@ public class Process {
} }
else else
{ {
JasperPrint jp = getJasperReportPrint( m_cs.getCtx(), pi); Trx trx = trxName == null ? Trx.get(Trx.createTrxName("WebPrc"), true) : Trx.get(trxName, true);
ByteArrayOutputStream wr = new ByteArrayOutputStream(); pi.setPrintPreview (false);
net.sf.jasperreports.engine.JasperExportManager.exportReportToPdfStream(jp, wr); pi.setIsBatch(true);
file_type ="pdf"; ProcessUtil.startJavaProcess(Env.getCtx(), pi, trx, true, null);
r.setData(wr.toByteArray()); file_type ="pdf";
r.setData(java.nio.file.Files.readAllBytes(pi.getPDFReport().toPath()));
r.setReportFormat(file_type); r.setReportFormat(file_type);
ok = true; ok = true;
} }
@ -674,32 +671,6 @@ public class Process {
return null; return null;
} }
private static JasperPrint getJasperReportPrint(Properties ctx, ProcessInfo pi)
{
try
{
JasperPrint jasperPrint;
ReportProcessor rp = new ReportProcessor(ctx, pi);
jasperPrint = rp.runReport();
if(jasperPrint == null)
{
log.finer("ReportStarter.startProcess Cannot process JasperPrint Object");
return null;
}
else
return jasperPrint;
}
catch (Exception ex)
{
log.saveError("ReportStarter.startProcess: Can not run report - ", ex);
return null;
// return ex.getMessage();
}
}
static public ReportEngine start (ProcessInfo pi) static public ReportEngine start (ProcessInfo pi)
{ {