• 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
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

JasperReports: "Error loading object from file" Exception

 
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.


 
Sheriff
Posts: 22037
108
Eclipse IDE Spring VI Editor Chrome Java Ubuntu 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
Posts: 22037
108
Eclipse IDE Spring VI Editor Chrome Java Ubuntu 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
Posts: 22037
108
Eclipse IDE Spring VI Editor Chrome Java Ubuntu 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
Posts: 22037
108
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
Hey! You're stepping on my hand! Help me tiny ad!
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic