Problems with JRLoader

0

Hi all, 

I'm having problems when using JRLoader.

Stack trace here:

net.sf.jasperreports.engine.JRException: Error loading object from file : C:\test\test.jrxml
at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:127)
at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:99)
at net.sf.jasperreports.engine.util.JRLoader.loadObjectFromFile(JRLoader.java:90)
at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:81)
at com.ebx.jasperReport.util.Test.generatePDFReport(Test.java:125)
at com.ebx.jasperReport.util.Test.main(Test.java:84)
Caused by: java.io.StreamCorruptedException: invalid stream header: 3C3F786D
 
at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
at java.io.ObjectInputStream.<init>(Unknown Source)
at net.sf.jasperreports.engine.util.ContextClassLoaderObjectInputStream.<init>(ContextClassLoaderObjectInputStream.java:58)
at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:122)
... 5 more
 
My code is here:
 
String rFile="C:\\test\\test.jrxml"; JasperReport jasperReport = (JasperReport) JRLoader.loadObject(rFile); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, map, new JREmptyDataSource());
Any idea where went wrong?
Thanks for your generous help.smiley
Elaine.
elainetmy's picture
Joined: Jun 13 2013 - 8:43pm
Last seen: 6 years 1 month ago

1 Answer:

0

JRLoader.loadObject loads serialized objects (such as compiled reports).  To load *.jrxml files you'll need to use JRXmlLoader.

Regards,

Lucian

lucianc's picture
7146
Joined: Jul 17 2006 - 1:10am
Last seen: 3 days 20 hours ago
Feedback
randomness