• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Jasper Problem

 
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All, I'm having a problem getting Jasper to work correctly.. I always get an Error Loading Object From InputStream exception on the JasperRunManager line...

my code is as follows..

try {
Connection con = com.dbws.king.DBConnection.getJNDIConnection();
response.setHeader("Cache-Control", "max-age=30");
response.setContentType("application/pdf");
response.addHeader("Content-Disposition", "attachment; filename=reportpdf.pdf");
ServletContext sc = getServletContext();
InputStream is = getServletContext().getResourceAsStream("WEB-INF/Reports/test2.jasper");
Map parameters = new HashMap();
JasperRunManager.runReportToPdfStream( is,response.getOutputStream(),parameters,con);
} catch(Exception e) {System.out.println(e.toString());}

whilst debugging I can confirm that is not null so the path to the file is correct and is being picked up, so i'm not sure why it would be having a problem with the InputStream. The .jasper file I created in iReport.

Any thoughts appreciated.
 
Dave Brown
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Solved the problem eventually.. so for the benefit of others who may run into this....

It was all down to the version of my jasper jar. I download jasper 0.6.6 and was using iReport which comes with version 0.6.4. The compiled .jasper file from iReport being version 0.6.4 was causing the problem so I copied the 0.6.4 jar from my jasper sdk into my tomcat common/lib directory and removed the 0.6.4 jar and all problems vanished.

Rgds,

Dave.
 
LOOK! OVER THERE! (yoink) your tiny ad is now my tiny ad.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic