• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JasperReports: "Error loading object from file" Exception

 
Lance Gray
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20546
56
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does file reps.jasper exist? The first argument to fillReportToFile is the source file name (or JasperReport object).
 
Lance Gray
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20546
56
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20546
56
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20546
56
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic