-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi to all!
I'm using ZK 5.0.5 and I'm new in the use of JasperReports.
With iReport 3.7.4 I have build my report2.jasper which show data from a table of my Oracle DB retrieved via JDBC connection.
I'have placed this report in my web application under WebContent/report/, and I've copied jasperreports-3.7.6.jar under the lib folder.
And this is the portion of code that recall the report:
<jasperreport id="report" src="/report/report2.jasper" type="pdf"/>
HTTP Status 410 - /view/z_0wu/zG8Pnp1/0/report/report2.pdf - <Jasperreport report> non trovata. -------------------------------------------------------------------------------- type Status report message /view/z_0wu/zG8Pnp1/0/report/report2.pdf - <Jasperreport report> non trovata. description The requested resource (/view/z_0wu/zG8Pnp1/0/report/report2.pdf - <Jasperreport report> non trovata.) is no longer available, and no forwarding address is known. -------------------------------------------------------------------------------- Apache Tomcat/6.0.26
Giordano
A few things I found with JasperReport and ZK:
1. The version of JR in ZK is not up to date, I had to use iReport 3.7.0 to generate a working .jasper file
2. The jasper file had to be in the WEB-INF folder (eg web/WEB-INF/reports/report.jasper)
3. Images used in the reports had to be in the classes folder (eg web/WEB-INF/classes/img/report.png)
to 1.) that's a problem from iReport not zk. There are many guys who uses an older version of iReport, because compiling problems.
to 2.) Right
// Get the real path for the report String reportSrc = Sessions.getCurrent().getWebApp().getRealPath("/WEB-INF/reports/order/Test_Report.jasper");
best
Stephan
hi everybody, i have the same trouble, and i think zk is finding the file report (*.jasper), but when zk tries to load the file generated (*.pdf), it can not find it, because the url is looking for, does not exists.
Look the message
message /view/z_0wu/zG8Pnp1/0/report/report2.pdf
the question is, do i need to do something more to show the report?
Example of my code
<zk>
<div >
<window>
Choose a File Type : <listbox id="format" mold="select" >
<listitem label="PDF" value="pdf" selected="true" />
<listitem label="HTML" value="html" />
<listitem label="Word (RTF)" value="rtf" />
<listitem label="Excel" value="xls" />
<listitem label="Excel (JXL)" value="jxl" />
<listitem label="CSV" value="csv" />
<listitem label="OpenOffice (ODT)" value="odt" unless="false" />
</listbox>
<button label="Get Report" onClick='showReport()' />
<jasperreport id="report" height="360px" />
<zscript><![CDATA[
import demo.reporting.jasperreport.CustomDataSource;
void showReport() {
//Preparing parameters
Map parameters = new HashMap();
report.setSrc("/application/operaciones/comision/reports/ComisionOficioSolicitud.jasper");
report.setDatasource(new CustomDataSource());
report.setType((String) format.getSelectedItem().getValue());
}
]]></zscript>
</window>
</div>
</zk>
all the jasper path file is under WEB-INF, i try at the same level, and inside WEB-INF, folder, but it still sends me
22/11/2010 01:47:36 PM org.zkoss.zk.au.http.AuDynaMediar process:130
GRAVE: Failed to load media, /view/gsjv/z_sj_k/0/jasper/reports/ComisionOficioSolicitud.pdf
>>java.lang.RuntimeException: resource for /jasper/reports/ComisionOficioSolicitud.jasper not found.
>> at org.zkoss.zkex.zul.Jasperreport.doReport(Jasperreport.java:337)
>> at org.zkoss.zkex.zul.Jasperreport.access$100(Jasperreport.java:76)
>> at org.zkoss.zkex.zul.Jasperreport$ExtraCtrl.getMedia(Jasperreport.java:310)
>> at org.zkoss.zk.au.http.AuDynaMediar.process(AuDynaMediar.java:112)
>> at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:362)
>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
>>...
Regards
// Get the real path for the report String reportSrc = Sessions.getCurrent().getWebApp().getRealPath("/WEB-INF/reports/order/Test_Report.jasper");
report.setSrc(reportSrc );
best
Stephan
Hello everyone!
Sorry if I answer only now, but I had to interrupt my work on ZK in recent weeks, and I have recently resumed.
Following the suggestions of FujitsuConsulting Stephan I solved my problems.
Here's the simplified version of the class that acts as a controller for the window that displays my report in pdf format.
package ecodata.gestedil.controller; import org.zkoss.util.media.AMedia; import org.zkoss.zk.ui.*; import org.zkoss.zk.ui.ext.AfterCompose; import org.zkoss.zul.*; import java.sql.Connection; import java.util.*; import org.zkoss.zkplus.hibernate.HibernateUtil; import net.sf.jasperreports.engine.*; @SuppressWarnings("serial") public class LonelyReport extends Window implements AfterCompose { private static final int dbMsgDebug = 1; private Iframe ifReport; private Textbox txProtocollo; String reportSrc = ""; String basicPath = "/WEB-INF/report/"; String reportRequired = (Sessions.getCurrent()).getAttribute("reportRequired").toString(); Long idPratica = Long.valueOf((Sessions.getCurrent()).getAttribute("idPratica").toString()); String outFileName = reportRequired+"_"+"Pratica"; public void afterCompose() { //wire variables Components.wireVariables(this, this); //auto forward Components.addForwards(this, this); this.showReport(); } private void showReport() { HashMap<Object, Object> hm = new HashMap<Object, Object>(); try { // Fill the report using DB connection Connection conn = HibernateUtil.currentSession().connection(); hm.put("ID_PRATICA", idPratica); hm.put("PROT", txProtocollo.getValue()); reportSrc = Sessions.getCurrent().getWebApp().getRealPath(basicPath+reportRequired+".jasper"); JasperPrint print = JasperFillManager.fillReport(reportSrc, hm, conn); if (dbMsgDebug != 0) System.out.println("Report --> reportSrc = "+reportSrc); // Export the PDF file and show it in iFrame AMedia am = new AMedia( outFileName+".pdf", null, null, JasperExportManager.exportReportToPdf(print)); ifReport.setContent(am); } catch (Exception e) { e.printStackTrace(); } } public LonelyReport() { // TODO Auto-generated constructor stub } public LonelyReport(String title, String border, boolean closable) { super(title, border, closable); // TODO Auto-generated constructor stub } }
Thanks, best regards,
Giordano
Hi,
I'm having the same problem generating my PDF file but everything works fine locally. When I deploy on a test server, I get the following error:
HTTP Status 410 - Failed to load /view/z_y9o/.../report/SRDIcontract.pdf
Cause: Unknown hyperlink target 0
Do any of you already had that kind of problem ONLY on a remote server?
Here's my code:
public void generatePDF(){ contractInfo.setLanguage(selectedObjectLanguage); generateContract(contractInfo, "pdf"); } void generateContract(ContractInfo contractInfo, String format){ String realPath = Executions.getCurrent().getDesktop().getSession().getWebApp().getRealPath("/"); File img = new File(realPath+File.separator+"media"+File.separator+"images"+File.separator+"cic.gif"); //calculate the amounts double total1= contractInfo.getWorkedHours() * contractInfo.getHourRate(); double total2 = contractInfo.getCalls() * contractInfo.getCallRate(); double finalTotal= total1 + total2 + contractInfo.getTravelingFees(); NumberFormat moneyFormatter = new DecimalFormat("#0.00$"); NumberFormat numberFormatter = new DecimalFormat("#0.00"); SimpleDateFormat hourFormat= new SimpleDateFormat("HH:mm"); //Preparing parameters Map parameters = new HashMap(); parameters.put("logo", img); parameters.put("name", contractInfo.getInterpreter().getFirstname() + " " + contractInfo.getInterpreter().getLastname() ); parameters.put("adresse1-2", (contractInfo.getInterpreter().getStreet()!=null? contractInfo.getInterpreter().getStreet():"") + " " + (contractInfo.getInterpreter().getStreet2()!=null? contractInfo.getInterpreter().getStreet2():"")); if(contractInfo.getInterpreter().getCity().length() == 0){ parameters.put("city-prov", (contractInfo.getInterpreter().getProvince()!=null? contractInfo.getInterpreter().getProvince():"")); } else{ parameters.put("city-prov", contractInfo.getInterpreter().getCity() + (contractInfo.getInterpreter().getProvince()!=null? ", " + contractInfo.getInterpreter().getProvince():"")); } parameters.put("postalCode", contractInfo.getInterpreter().getPostalCode()); parameters.put("fileNumber", (contractInfo.getFileNo()!=null && !contractInfo.getFileNo().equals(0L)) ? contractInfo.getFileNo().toString(): ""); parameters.put("contractDate", (contractInfo.getContractDate()!=null? new SimpleDateFormat("yyyy-MM-dd").format(contractInfo.getContractDate()):"")); parameters.put("location", contractInfo.getOffice().getName()); parameters.put("period1",(contractInfo.getPeriods()!=null && contractInfo.getPeriods().size()>=1 ? hourFormat.format(contractInfo.getPeriods().get(0).getFrom()) + "-" + hourFormat.format(contractInfo.getPeriods().get(0).getTo()):"")); parameters.put("period2",(contractInfo.getPeriods()!=null && contractInfo.getPeriods().size()>=2 ? hourFormat.format(contractInfo.getPeriods().get(1).getFrom()) + "-" + hourFormat.format(contractInfo.getPeriods().get(1).getTo()):"")); parameters.put("period3",(contractInfo.getPeriods()!=null && contractInfo.getPeriods().size()>=3 ? hourFormat.format(contractInfo.getPeriods().get(2).getFrom()) + "-" + hourFormat.format(contractInfo.getPeriods().get(2).getTo()):"")); parameters.put("period4",(contractInfo.getPeriods()!=null && contractInfo.getPeriods().size()>=4 ? hourFormat.format(contractInfo.getPeriods().get(3).getFrom()) + "-" + hourFormat.format(contractInfo.getPeriods().get(3).getTo()):"")); parameters.put("languages", contractInfo.getLanguage().getName()); parameters.put("resquestingOffice", contractInfo.getOffice().getId().toString()); parameters.put("byPhone", (byPhone.isChecked() ? "Par téléphone / By phone" : "X")); parameters.put("sin", contractInfo.getInterpreter().getSin()!=null? contractInfo.getInterpreter().getSin().toString(): ""); parameters.put("hours1", numberFormatter.format(contractInfo.getWorkedHours())); parameters.put("hourRate", moneyFormatter.format(contractInfo.getHourRate())); parameters.put("hours2",numberFormatter.format(contractInfo.getCalls())); parameters.put("callRate", moneyFormatter.format(contractInfo.getCallRate())); parameters.put("total1", moneyFormatter.format(total1)); parameters.put("total2", moneyFormatter.format(total2)); parameters.put("travelExpenses", moneyFormatter.format(contractInfo.getTravelingFees())); parameters.put("finalTotal", moneyFormatter.format(finalTotal)); parameters.put("SUBREPORT_DIR", realPath+File.separator+"report"+File.separator); report.setSrc("/report/SRDIcontract.jasper"); report.setParameters(parameters); report.setType(format); }
hi everyone, I have this problem when running the jasper Caused by: net.sf.jasperreports.engine.util.JRFontNotFoundException: Font ' net/sf/jasperreports/fonts/pictonic/pictonic.ttf net/sf/jasperreports/fonts/pictonic/pictonic.svg net/sf/jasperreports/fonts/pictonic/pictonic.eot net/sf/jasperreports/fonts/pictonic/pictonic.woff ' is not available to the JVM. See the Javadoc for more details.
someone can help me
Asked: 2010-11-16 08:55:26 +0800
Seen: 1,719 times
Last updated: Nov 16 '14