Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Other Open Source Projects and the fly likes Jasper Report Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Jasper Report" Watch "Jasper Report" New topic
Author

Jasper Report

Avinash Srivastava
Greenhorn

Joined: Feb 19, 2013
Posts: 2
Hello All,

I am getting following exception while reading an JRXML file.
java.io.StreamCorruptedException: invalid stream header: 3C3F786D
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:802)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:299)
at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:87)
at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:64)
at rnd.StudentReport.main(StudentReport.java:46)

The source code is as :

import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.util.JRLoader;
import net.sf.jasperreports.view.JasperViewer;

public class StudentReport {


public InputStream loadJRXMLFile()
{
InputStream in=null;
try
{
in = this.getClass().getClassLoader().getResourceAsStream("D:/report/report10.jrxml");

}
catch (Exception e) {
e.printStackTrace();
}

return in;
}

public static void main(String args[])
{
try
{
/* StudentReport SR=new StudentReport();
InputStream in=SR.loadJRXMLFile();

JasperReport jasperReport = JasperCompileManager.compileReport(in);*/

String filePath = "D:/report/studentreport.jrxml";

JasperDesign jasperDesign = (JasperDesign)JRLoader.loadObject(filePath);


JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);


Map parameters = new HashMap();
parameters.put("roll_no", "01");
parameters.put("student_Name", "aaa");
parameters.put("class", "X");
parameters.put("marks", "1000");
parameters.put("result","Pass");
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters);
JasperExportManager.exportReportToPdfFile(jasperPrint, "D:/report/SReport.pdf");

JasperViewer.viewReport(jasperPrint);



}
catch (JRException e) {
e.printStackTrace();
}
catch (Exception e) {
e.printStackTrace();
}
}
}

Kindly help me as soon as possible.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jasper Report
 
Similar Threads
Jasper Reports Exception
Error while running in ecllipse.
Struts 2 - JasperReport problem
Error loading object from file in JasperReport Can any one Help...
jasper reports -Plz help me out