Jump to content
Changes to the Jaspersoft community edition download ×

iReport/Java issue

2004 IR Help

Recommended Posts

By: PhotoGrey - photogrey

iReport/Java issue

2004-07-24 13:12



I am trying to create a pdf file using Java. However, I keep getting this error:


Error loading object from File


I believe that it is complaining about my subReport that I have embedded in the main report, but I never had this problem when testing in iReports.


Do I have to specify the subreport within the Java code, or is there a property that I have to tweek in iReports?


Any help is appreciated.







By: PhotoGrey - photogrey

RE: iReport/Java issue

2004-07-26 12:46

Sorry about the lack of information on my problem, here's the java code for the strut action...


PrintWriter out = response.getWriter();


conMan = DBConnectionManager.getInstance();

dbConn = conMan.getConnection("poolname");


Map parameters = new HashMap();

parameters.put("CompanyID", CompanyID);


JasperPrint jrPrint = JasperManager.fillReport("/www/tomcat41/webapps/cst1833/richmondProject/reports/" + report, parameters, dbConn);


JasperManager.printReportToPdfFile(jrPrint, "/www/tomcat41/webapps/cst1833/richmondProject/Bordereau.pdf");


request.setAttribute("message", "Report created");

nextPage = mapping.findForward("success");


The main report takes a parameter from java (companyID) and the sub report that I have in the main report takes a parameter from the main report. As far as I can tell, the error is happening on trying to load the sub report.


btw, I'm running this off of a Lunix box.


Thanks for any help.







By: Juan Ara - fi2net@Spain - laureke

RE: iReport/Java issue

2004-07-27 10:01

First of all, I'll recomend u to have a action dispatcher for printing reports... I mean, look at new JasperReports 0.6 and think about changing 50+ actions to the new package names or just an actionDispatcher for it... ;)


Second, at that servlet (dispatcher) I've something like this:


private static boolean print(JasperPrint jasperPrint, HttpServletResponse response, String fileName) {

ByteArrayOutputStream baos=new ByteArrayOutputStream();

ServletOutputStream out=null;


JasperPrintManager myJPM = new JasperPrintManager();


try {







response.setHeader("Content-disposition","inline; filename=listado.pdf" );


if (fileName!=null) {

response.setHeader("Content-disposition","attachment; filename="+fileName);







} catch (Exception e) {

try {baos.close();} catch (IOException ex) {;}

return false;


return true;



And then, each "dispatch" has something like this:


public ActionForward reportprint1 (

ActionMapping mapping,

ActionForm form,

HttpServletRequest request,

HttpServletResponse response)

throws Exception {


String embarque=request.getParameter("embarque");


if (embarque==null||embarque.equals("")) throw new es.sgv.exceptions.ImprimirException("indicacionesS4Embarque: Falta parametro de impresion");



Connection trans= singleTonPool.getConnection();


DSFactory temp=new DSFactory();


JRRewindableDataSource ds=temp.getDs1(trans,embarque);

JRRewindableDataSource ds1=temp.getDs2(trans,embarque);

JRRewindableDataSource ds2=temp.getDs3(trans,embarque);

if (!ds.next()) return mapping.findForward(noData);



String sub1=getServlet().getServletContext().getRealPath("/jasper/subreport1.jasper");

String sub2=getServlet().getServletContext().getRealPath("/jasper/subreport2.jasper");



Map parameters = new HashMap();







JasperPrint jasperPrint=JasperManager.fillReport(getServlet().getServletContext().getRealPath("/jasper/report.jasper"),parameters,ds);


boolean result=imprimir(jasperPrint,response,null); //no filename


//If any error, throw a mapped (struts-config) exception

if (!result) throw new es.sgv.exceptions.ImprimirException("Report Error: Printing Error");


return null;

} //action end





By: Juan Ara - fi2net@Spain - laureke

RE: iReport/Java issue

2004-07-27 10:03



boolean result=imprimir(jasperPrint,response,null); //no filename


should be


boolean result=print(jasperPrint,response,null); //no filename


(A mistake when translating my servlet ;) )





By: superzech - superzech

RE: iReport/Java issue

2004-07-29 00:51


when i try to run JasperManager.fillReport(XXX), an error saying -

Cannot resolve symbol:Method fillReport(java.lang.String,java.util.HashMap..


may i know whats the problem?



Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...