File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Murach's Java Servlets and JSP this week in the Servlets 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.
 
Don't get me started about those stupid light bulbs.
 
subject: Jasper Report
 
Similar Threads
Error loading object from file in JasperReport Can any one Help...
Struts 2 - JasperReport problem
jasper reports -Plz help me out
Jasper Reports Exception
Error while running in ecllipse.