aspose file tools
The moose likes Java in General and the fly likes JasperReports: Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "JasperReports: "Error loading object from file" Exception" Watch "JasperReports: "Error loading object from file" Exception" New topic
Author

JasperReports: "Error loading object from file" Exception

Lance Gray
Greenhorn

Joined: Dec 06, 2011
Posts: 20
So, I'm testing out how JasperReports works. I downloaded iReport so that I can make quick reports, too. I am using CSV files as a data source for my report. The problem is this. Whenever I run the program, it gives me this Exception in thread "main" net.sf.jasperreports.engine.JRException: Error loading object from file : reps.jasper error. How do I fix this?

Here are my codes so far.



And here is my .jasper file generated by iReport.


Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

Does file reps.jasper exist? The first argument to fillReportToFile is the source file name (or JasperReport object).


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Lance Gray
Greenhorn

Joined: Dec 06, 2011
Posts: 20
Rob Spoor wrote:Does file reps.jasper exist? The first argument to fillReportToFile is the source file name (or JasperReport object).

Yes, it does. reps.jasper contains the XML code I posted above. Should I not have placed that code there?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

That's not a problem. It may help someone else see a flaw in it. As I see it, there are two possible causes of the error:
1) the file cannot be read.
2) the file does not contain what it should.
I haven't worked with JasperReports so I only focus on the first possible cause.

OK, so there is a file reps.jasper. But is it located in the right location? What do you get when you add this at line 28:
Perhaps that's not what you expect it to be.
Lance Gray
Greenhorn

Joined: Dec 06, 2011
Posts: 20
No, it still doesn't work. I've even replaced "reps.jasper" with new File("reps.jasper").getAbsolutePath() but it still gives me the same error.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

Did the printout I suggested print what you expected? If so, what do the following print:
If both print true then there probably is a mistake in the file itself, although I couldn't tell you where or what.
Lance Gray
Greenhorn

Joined: Dec 06, 2011
Posts: 20
It seems that the mistake was on the Jasper codes itself. I had a friend help me on this and it turned out I missed a few lines of code. Thanks for the help.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

You're welcome.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: JasperReports: "Error loading object from file" Exception
 
Similar Threads
jasper report- error
exported Jasper Report has different look than preview in IReport designer
Showing blank page while running the report in Jasper
PDF with jsf
Unable to export Jasper Report in html format.