wood burning stoves 2.0*
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


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Jasper Problem" Watch "Jasper Problem" New topic
Author

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.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.


Regards, Dave Brown
SCJP 6 - [url]http://www.dbws.net/[/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.

Rgds,

Dave.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jasper Problem