yazanki Posted January 13, 2014 Share Posted January 13, 2014 I'm developing a new project JSF2.0 with MAVEN, PRIMEFACES, HIBERNATE and SPRING SECURITY WEB, when i try generate a report i get this error: java.lang.ClassCastException: cannot assign instance of net.sf.jasperreports.engine.base.JRBaseTextField to field net.sf.jasperreports.engine.base.JRBaseParagraph.paragraphContainer of type net.sf.jasperreports.engine.JRParagraphContainer in instance of net.sf.jasperreports.engine.base.JRBaseParagraph Any idea? Link to comment Share on other sites More sharing options...
Ankur Gupta Posted January 14, 2014 Share Posted January 14, 2014 Hi,Probably this happens when you try to use an older version of Jasper Report Jar file, Are you using iReport/ Jasper Soft studio ? If yes then what version are you using?Probably there is a version mismatch . Hope that this helps ThanksAnkur Gupta Link to comment Share on other sites More sharing options...
yazanki Posted January 14, 2014 Author Share Posted January 14, 2014 i'm using jaspersoft 5.5.0 and netbeans ide 7.4 with ireport plugin for 5.5.0 Link to comment Share on other sites More sharing options...
yazanki Posted January 14, 2014 Author Share Posted January 14, 2014 this is my libs... i'm using a maven project. Link to comment Share on other sites More sharing options...
yazanki Posted January 14, 2014 Author Share Posted January 14, 2014 try { FacesContext facesContext = FacesContext.getCurrentInstance(); facesContext.responseComplete(); ServletContext scontext = (ServletContext) facesContext.getExternalContext().getContext(); JasperPrint jasperPrint = JasperFillManager.fillReport(scontext.getRealPath("/WEB-INF/reports/report.jasper"), parametros, new JRBeanCollectionDataSource(listaOler)); ByteArrayOutputStream baos = new ByteArrayOutputStream(); JRPdfExporter exporter = new JRPdfExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos); exporter.exportReport(); byte[] bytes = baos.toByteArray(); if (bytes != null && bytes.length > 0) { HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse(); response.setContentType("application/pdf"); response.setHeader("Content-disposition", "inline; filename="olerite.pdf""); response.setContentLength(bytes.length); ServletOutputStream outputStream = response.getOutputStream(); outputStream.write(bytes, 0, bytes.length); outputStream.flush(); outputStream.close(); } } catch (Exception e) { e.printStackTrace(); } Link to comment Share on other sites More sharing options...
Ankur Gupta Posted January 14, 2014 Share Posted January 14, 2014 Hi,The ClassCastException and the duplicate component warning indicate that you have two JasperReports jars on your classpath.Please check for the duplicate jars. If this is not the issue then youare probably using a Static Text field in your report where you need to be using a Text Field. Hope that this helps ThanksAnkur Guptahttp://ankurthetechie.blogspot.in/ 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