Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Jasper Report

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
If you are using a rototiller, you are doing it wrong. Even on this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!