2005 IR Help Posted August 27, 2006 Share Posted August 27, 2006 By: Tom Schindl - tomsontom ClassCastException when exporting 2004-09-01 08:56 Hi, I'm running into problems when I try to export my jasper-File to any format, I get the following exception: --------------8<-------------- java.lang.ClassCastException: net.sf.jasperreports.engine.JasperReport at net.sf.jasperreports.engine.JasperExportManager.exportReportToPdfFile(JasperExportManager.java:104) ..... --------------8<-------------- The code is the following: --------------8<-------------- JasperCompileManager.compileReportToFile("C:\Dokumente und Einstellungen\tom-admin\Eigene Dateien\eclipsehome\biscat\src\reports\employee_basedata.jrxml"); System.out.println("It's compiled"); JasperFillManager.fillReport("C:\Dokumente und Einstellungen\tom-admin\Eigene Dateien\eclipsehome\biscat\src\reports\employee_basedata.jasper",collector.getParameters(),connection); System.out.println("It's filled"); JasperExportManager.exportReportToPdfFile("C:\Dokumente und Einstellungen\tom-admin\Eigene Dateien\eclipsehome\biscat\src\reports\employee_basedata.jasper"); System.out.println("It's exported"); --------------8<-------------- I've also tried the HorizontalReport-example but I get the same exception. What am I doing wrong? Tom Link to comment Share on other sites More sharing options...
jackiema Posted March 27, 2007 Share Posted March 27, 2007 Hi, I am getting the exactly same error. It worked only on "fill". Not for pdf, xml, html... anything. Have anyone got the answer yet? Please help! Thanks, Jackie Link to comment Share on other sites More sharing options...
jackiema Posted March 28, 2007 Share Posted March 28, 2007 Still struggling with no clue. Please help me if anyone knows what the problem is. Here is my console:java.lang.ClassCastException: net.sf.jasperreports.engine.JasperReport at net.sf.jasperreports.engine.JasperExportManager.exportReportToPdfFile(JasperExportManager.java:77) at HelloWorldApp.main(HelloWorldApp.java:115) And in the class, I am using JasperExportManager as: JasperExportManager.exportReportToPdfFile(fileName); The report is the as simple as: <?xml version="1.0"?><!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> <jasperReport name="Simple_Report"> <detail> <band height="20"> <staticText> <reportElement x="180" y="0" width="200" height="20"/> <text><![CDATA[Hello World!]]></text> </staticText> </band> </detail></jasperReport> So I guess it has nothing to do with the file. But I am using both jasper jars and project code from 1.2.4 and it compiled fine. Thanks Jackie Link to comment Share on other sites More sharing options...
lucianc Posted March 28, 2007 Share Posted March 28, 2007 JasperExportManager.exportReportToPdfFile(String filename) expects the file passed as parameter to contain a serialized JasperPrint object, but you are probably passing a *.jasper file which contains a serialized JasperReport object. HTH,Lucian Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now