954,536 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

JASPER REPORT...class not found exception

Hello to All,
I want to use basic jasper report utility....
But facing error as mentioned below,
please help me.....I'm beginer of JReport

import java.io.File;
import java.util.HashMap;

import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;

import net.sf.jasperreports.engine.*;
import net.sf.jasperreports.engine.util.JRLoader;
import net.sf.jasperreports.engine.util.JRSaver;
import net.sf.jasperreports.engine.xml.*;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.export.JRPdfExporter;
import net.sf.jasperreports.engine.export.JRPrintServiceExporter;
import net.sf.jasperreports.engine.export.JRPrintServiceExporterParameter;
import net.sf.jasperreports.view.JRViewer;
import net.sf.jasperreports.view.JasperDesignViewer;

public class water_bill {

	
	public static void main(String[] args) {
		new water_bill().generateReport();

	}

	private void generateReport() {
		JasperReport jasperReport = null;
		JasperDesign jasperDesign = null;
		JasperPrint report = null;
		
		try
		{
			//jasperDesign =JRXmlLoader.load(new File("C:/JASPER_NEW/trialJasper//trialjasper/reports/abc.java"));
			jasperReport = JasperCompileManager.compileReport("C:/JASPER_NEW/trialJasper//trialjasper/reports/abc.java");
			report = JasperFillManager.fillReport(jasperReport,new HashMap());
			JRViewer jrViewer = new JRViewer(report);
		}
		catch(JRException e)
		{
			e.printStackTrace();
		}
	}

}


Error is as follow,Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/digester/Digester
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:142)
at water_bill.generateReport(water_bill.java:37)
at water_bill.main(water_bill.java:25)

vishal18
Newbie Poster
10 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

Make sure you have the Jasper report jars on your class path.

Ezzaral
Posting Genius
Moderator
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
 

Thanks Ezzaral.....It worked.

But with new problem....

now there is a message window "The document has no pages"

whats wrong now???

vishal18
Newbie Poster
10 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

I have no idea. I have not used Jasper Reports. You'll need to consult the documentation for that.

Ezzaral
Posting Genius
Moderator
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
 

The document has no pages is an indication that your data source did not return any data. If you are using a database and SQL, check your SQL statement outside of jasper reports. If it doesn't return any rows, that is your issue.

To change the behavior of jasper reports when the data source comes back empty, see the report settings.

rpbarbati
Newbie Poster
2 posts since Dec 2011
Reputation Points: 10
Solved Threads: 1
 

Also, regarding your use of the Jasper Report Compiler, the compiler is used to compile the .JRXML file into java. It is not used to compile a .java file, as you are attempting to do.

So, in general, to produce a report from java, you will use something like...

// Load the jrxml file
JasperDesign jasperDesign = JRXmlLoader.load(fileName);

// Compile the jrxml file
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);

// Produce the report (fill the report with data)
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameterMap, connection);

// Export to HTML for web or view the report in JasperViewer for local
rpbarbati
Newbie Poster
2 posts since Dec 2011
Reputation Points: 10
Solved Threads: 1
 

Thanks RP..
But its too late now.... :)
Now I have better hand on Jasper Reports...

thanks again for reply....

vishal18
Newbie Poster
10 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You