-
FEATURED COMPONENTS
First time here? Check out the FAQ!
im trying to create a report with ireport 3.7.6 and i cant, i already import all libraries from ireport,common.digester, etc. this is the code im using
<?page title="reporte" contentType="text/html;charset=UTF-8"?>
<zk>
<window title="reporte" border="normal" onCreate="" height="800px">
<zscript><![CDATA[//@IMPORT
import net.sf.jasperreports.*;
import java.util.*;
import net.sf.jasperreports.engine.*;
import java.util.*;
import java.lang.*;
]]></zscript>
<jasperreport id="ireport" height="600px" width="700px" />
<zscript><![CDATA[//@DECLARATION
void reporte(){
try {
ireport.setSrc("report1.jasper");
}catch(Exception e){
e.printStackTrace();
}
}
]]></zscript>
<button label="reporte" onClick="reporte()">
</button>
</window>
</zk>
and this is the console error:
INFO: Source is changed: /reporte.zul
29/12/2010 09:42:29 org.zkoss.zk.au.http.AuDynaMediar process:130
GRAVE: Failed to load media, /view/gvrp1/z_vr_2/0/report1.pdf
>>java.lang.NullPointerException
>> at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89)
>> at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601)
>> at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:582)
>> at org.zkoss.zkex.zul.Jasperreport.doReport(Jasperreport.java:361)
>> at org.zkoss.zkex.zul.Jasperreport.access$100(Jasperreport.java:76)
>> at org.zkoss.zkex.zul.Jasperreport$ExtraCtrl.getMedia(Jasperreport.java:310)
>>...
please i need help
Hi Victorino,
try this:
and copy to your WEB-INF/lib
best regards
Pedro
thanks pymsoft but doesnt work i already have that jar on my files... have you another idea please?
Your best bet at this point is to grab some code from the internet that shows how to load the .jasper file from your Java code directly without using any ZK stuff and see if you can successfully run the JasperFillManager.fillReport(.....) method...here's some old code of mine:
JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(equipmentList) ; try { reportURL = getClass( ).getClassLoader( ).getResource( "/reports/" + reportFile + ".jasper" ); reportDirectory = URLDecoder.decode( reportURL.getPath( ), "UTF-8" ); } catch (UnsupportedEncodingException e) { reportDirectory = reportURL.getPath( ); } reportDirectory = reportDirectory.substring( 0, reportDirectory.lastIndexOf( '/' ) + 1 ); jasperPrint = JasperFillManager.fillReport( reportDirectory + reportFile + ".jasper", (Map<String, Object>)parameters, ds ); if( "pdf".equalsIgnoreCase(reportType) ) { OutputStream ouputStream = response.getOutputStream(); response.setContentType("application/pdf"); exporter = new JRPdfExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream); exporter.exportReport(); }
I create my reports to be driven from a collection of objects. This example uses an ArrayList<VREquipment> for the collection being passed to create the JRBeanCollectionDataSource. This code was in a method that had (HttpServletRequest request, HttpServletResponse response) in its parameter list, hence, its ability to write the PDF to the ouputStream.
My gut feel is the datasource is not working properly in your report. How'd you specify your datasource in iReport? Is it JDBC or JRBeanCollectionDataSource or something else?
Victorino,
try with this sample first:
http://books.zkoss.org/wiki/Small_Talks/2010/December/Report_with_ZK:_JasperReports_Component
regards
Pedro
thanks for help me guys, but i still have the problem, caclark im tried de datasource on two ways whit a java clas doind a getfield and nothing, whit a jdbc its the same problem
29/12/2010 09:42:29 org.zkoss.zk.au.http.AuDynaMediar process:130 GRAVE: Failed to load media, /view/gvrp1/z_vr_2/0/report1.pdf >>java.lang.NullPointerException >> at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89) >> at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601) >> at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:582) >> at org.zkoss.zkex.zul.Jasperreport.doReport(Jasperreport.java:361) >> at org.zkoss.zkex.zul.Jasperreport.access$100(Jasperreport.java:76) >> at org.zkoss.zkex.zul.Jasperreport$ExtraCtrl.getMedia(Jasperreport.java:310)
The only time I've seen this was using iReport 3.7.6 to compile the report but having jasperreports-3.1.2.jar in WEB-INF/lib. Once that was updated properly, things were fine. We don't know your development environment. Are you using Eclipse + Tomcat or what? If it's Eclipse + Tomcat, make sure you have successfully rebuilt your project and republished it to your Tomcat instance.
Hi there.
This is probably a class'path' error. in other words... where is ireport.setSrc("report1.jasper"); <---- where is this file at execution time?.
you should try to load the .jxml or .jasper file like caclark suggested
... reportURL = getClass( ).getClassLoader( ).getResource( "/reports/" + reportFile + ".jasper" );...
or maybe just as a test try to put the jasper under /web-inf/whatever_path just to see if it a libs or path issue
... Execution exe = Executions.getCurrent(); is = exe.getDesktop().getWebApp().getResourceAsStream(exe.toAbsoluteURI("/WEB-INF/<reports>/.../<reports_path>/areport.jasper", false)); ...
just and idea.
im using eclipse galileo,zk 3.0.6,tomcat 6 , ireport 3.7.6, i have on WEB-INF/lib jasperreport.jar, jasperreport 3.7.6.jar and this is my code:
<?page title="reporte" contentType="text/html;charset=UTF-8"?> <zk> <window title="reporte" id="documento" border="normal" onCreate="reporte()" height="800px"> <zscript> <![CDATA[//@IMPORT import gerencia.java.*; ]]> </zscript> <script> <zscript> DataReporte fdc = new DataReporte(); </zscript> </script> <zscript><![CDATA[//@DECLARATION void reporte()throws Exception{ try { String ruta=("/prueba.jasper"); reporte.setSrc(ruta); reporte.setDatasource(fdc); reporte.setVisible(true); }catch(Exception ex){ ex.fillInStackTrace(); } } ]]></zscript> <div> <jasperreport id="reporte" width="100%" height="600px" visible="false" /> </div> </window> </zk>
the file prueba.jasper its in WebContent folder and this its the exeption
25/01/2011 08:48:43 org.zkoss.zk.au.http.AuDynaMediar process:130 GRAVE: Failed to load media, /view/g3l41/z_3l_4/0/prueba.pdf >>java.lang.NullPointerException >> at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89) >> at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:628) >> at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:609) >> at org.zkoss.zkex.zul.Jasperreport.doReport(Jasperreport.java:361) >> at org.zkoss.zkex.zul.Jasperreport.access$100(Jasperreport.java:76) >> at org.zkoss.zkex.zul.Jasperreport$ExtraCtrl.getMedia(Jasperreport.java:310)
i have on WEB-INF/lib jasperreport.jar, jasperreport 3.7.6.jar
Uh, no...that's two different versions of the same jar file...not good; results unpredictable. Remove jasperreport.jar, rebuild, republish, retest.
Uh, no...that's two different versions of the same jar file...not good; results unpredictable. Remove jasperreport.jar, rebuild, republish, retest.
nothing works, i remove the jasperreport.jar and nothing
Asked: 2010-12-29 08:21:50 +0800
Seen: 1,855 times
Last updated: Sep 23 '11