Help coderanch get a
new server
by contributing to the fundraiser
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

JasperReports: "Error loading object from file" Exception

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 22796
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 22796
131
Eclipse IDE Spring Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 22796
131
Eclipse IDE Spring Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 22796
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the same problem, I use exists() and canRead()) and the result was false
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic