File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other JSE/JEE APIs and the fly likes Jasper Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Jasper Problem" Watch "Jasper Problem" New topic

Jasper Problem

Dave Brown
Ranch Hand

Joined: Mar 08, 2005
Posts: 301
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.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.

Regards, Dave Brown
SCJP 6 - [url][/url] - Check out Grails Forum
Dave Brown
Ranch Hand

Joined: Mar 08, 2005
Posts: 301
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.


I agree. Here's the link:
subject: Jasper Problem
It's not a secret anymore!