0

need help ireport + zk

asked 2010-12-29 08:21:50 +0800

victorinox134 gravatar image victorinox134
24 1

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

delete flag offensive retag edit

16 Replies

Sort by ยป oldest newest

answered 2010-12-30 09:23:59 +0800

pymsoft gravatar image pymsoft
133 5

Hi Victorino,


try this:

download http://sourceforge.net/projects/jasperreports/files/jasperreports/JasperReports%203.7.6/jasperreports-3.7.6.jar/download

and copy to your WEB-INF/lib

best regards

Pedro

link publish delete flag offensive edit

answered 2011-01-11 13:15:13 +0800

victorinox134 gravatar image victorinox134
24 1

thanks pymsoft but doesnt work i already have that jar on my files... have you another idea please?

link publish delete flag offensive edit

answered 2011-01-11 18:59:46 +0800

caclark gravatar image caclark
1753 2 5
http://clarktrips.intltwi...

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?

link publish delete flag offensive edit

answered 2011-01-12 02:22:02 +0800

pymsoft gravatar image pymsoft
133 5

Victorino,

try with this sample first:

http://books.zkoss.org/wiki/Small_Talks/2010/December/Report_with_ZK:_JasperReports_Component


regards


Pedro

link publish delete flag offensive edit

answered 2011-01-24 15:05:49 +0800

victorinox134 gravatar image victorinox134
24 1

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)

link publish delete flag offensive edit

answered 2011-01-24 17:11:41 +0800

caclark gravatar image caclark
1753 2 5
http://clarktrips.intltwi...

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.

link publish delete flag offensive edit

answered 2011-01-25 03:13:26 +0800

mikelara gravatar image mikelara
144
www.mextisa.com.mx

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.

link publish delete flag offensive edit

answered 2011-01-25 07:21:39 +0800

victorinox134 gravatar image victorinox134
24 1

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)


link publish delete flag offensive edit

answered 2011-01-25 08:51:27 +0800

caclark gravatar image caclark
1753 2 5
http://clarktrips.intltwi...

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.

link publish delete flag offensive edit

answered 2011-01-25 14:50:49 +0800

victorinox134 gravatar image victorinox134
24 1

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

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2010-12-29 08:21:50 +0800

Seen: 1,855 times

Last updated: Sep 23 '11

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More