dabor Posted March 3, 2009 Share Posted March 3, 2009 Hi to all.I'm making a simple report-subreport hierarchy. I insert the subreport (existing subreport.jasper file) into report.jasper, they are in the same folder. I set the subreport expression to "subreport.jasper" as they are in the same folder.I recompile both report and subreport and run the report. It all works well.But the problem is that this doesn't work from the java desktop application. I get the exception:Could not load object from location : subreport.jasperI also tried to add the report/subreport folder to the classpath, but that didn't help either. So, how to add subreports so that they work from the application too? So far I didn't find anything useful, even searching this forum. Can anyone help me out, please? I desperately need help! Any hint or pointer would be greatly appreciated!Thanks alot!DB Link to comment Share on other sites More sharing options...
yo1832 Posted March 3, 2009 Share Posted March 3, 2009 when you select put the subreport in report, the program give 2 option for the path of subreport.relative or pass a path for parameterYou are select pass the path for parameter.You must create a parameter with the path of subreport.the name of this parameter you can see in wiew -> parameter of report Link to comment Share on other sites More sharing options...
dabor Posted March 3, 2009 Author Share Posted March 3, 2009 Thanks for a quick reply. And how do I get reports path for (deployed) java application? The subreport is in the same folder as a main report, if that helps. Thanks in advance. Link to comment Share on other sites More sharing options...
yo1832 Posted March 3, 2009 Share Posted March 3, 2009 if your report is in the same folder, go subreport propertis -> subreport(others) in this tab java.lang.String $P{SUBREPORT_DIR} + "myreport.xxx" change the last line for your subreport ".\myreport.xxx" Link to comment Share on other sites More sharing options...
dabor Posted March 3, 2009 Author Share Posted March 3, 2009 Yes, but that works only if I run main report from iReport. If I run the report from java app, I get the exception Could not load object from location : subreport.jasper. I found a lot of people had the same problem, but no useful solutions (yet)... Link to comment Share on other sites More sharing options...
yo1832 Posted March 3, 2009 Share Posted March 3, 2009 I make this: //Read Bd List listaAnunciosP = this.fachada.obtenerAnunciosPorEstadoParaImpresion(anuncioBean, busqueda); File reportFile = new File(getServlet().getServletContext().getRealPath("//WEB-INF//classes//reportes//busquedaAnunciosImpresionBoletin.jasper")); parametros.put("rutaImagen", imagenLogo.getPath()); //This are constantes with the path parametros.put("imagenLogoBoc", imagenLogoBoc.getPath()); parametros.put("imagenLogoCruz", imagenLogoCruz.getPath()); parametros.put("subreportPath", "//WEB-INF//classes//reportes//"); //Parameter with the for subreport listaObjetosReportar = listaAnunciosP; JasperReport jasperReport = (JasperReport)JRLoader.loadObject(reportFile.getPath()); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parametros, new JRBeanCollectionDataSource(listaObjetosReportar)); response.setContentType("application/pdf"); response.setHeader("Content-Disposition", "attachment; filename=vistaprevia.pdf"); response.setHeader("Expires", "0"); response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); response.setHeader("Pragma", "public"); response.getOutputStream().write(jasperPrint); In my report propertys subreport propertis -> subreport(others) in this tab java.lang.String $P{subreportPath} + "subBusquedaAnunciosImpresionBoletin.jasper" Link to comment Share on other sites More sharing options...
dabor Posted March 3, 2009 Author Share Posted March 3, 2009 Looks like this is the "main" line:parametros.put("subreportPath", "//WEB-INF//classes//reportes//"); My report/subreport path is something like this (since it's a desktop app):com/company/project/reports (java way com.company.projects.reports). They are inside jar file. Can I set the path into the jar file? Thanks. Link to comment Share on other sites More sharing options...
yo1832 Posted March 4, 2009 Share Posted March 4, 2009 In my aplication, the reports are in src.main.resorces.reports, but this in package view of the program that i use for program. You must put the real path. parametros.put("subreportPath", directoryHowIsInstallAplication+realPathReports); Link to comment Share on other sites More sharing options...
dabor Posted March 4, 2009 Author Share Posted March 4, 2009 Thank you for barring with me. Can I get the path in my application? The program can be installed in different folders. Another thing: the reports don't extract when I install the app, they remain in JARs... Can I specify path into JARs? Any other idea or direction?Thanks alot! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now