Imz Posted August 23 Share Posted August 23 I am currently upgrading the JasperReports Library from version 6.0.4 to 7.0.0. My system is currently using the following JasperReports libraries: - jasperreports-fonts-6.0.4.jar - jasperreports-javaflow-6.0.4.jar After upgrading these libraries, along with their dependencies and other JasperReports libraries: - jasperreports-7.0.0.jar - jasperreports-jdt-7.0.0.jar The system throws an error when attempting to download the report (PDF). My system using Java Servlet. System Error: ERROR http-nio-8080-exec-3 OCSASTDFP :: [O00045.java:281] :: net.sf.jasperreports.engine.JRException: Unable to load report at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:172) at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:149) at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:136) ... Tomcat Error: org.apache.struts2.dispatcher.DefaultDispatcherErrorHandler - Exception occurred during processing request: Cannot invoke "java.io.PrintWriter.print(String)" because "this.pw" is null java.lang.NullPointerException: Cannot invoke "java.io.PrintWriter.print(String)" because "this.pw" is null at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] at ognl.OgnlRuntime.invokeMethodInsideSandbox(OgnlRuntime.java:1245) ~[ognl-3.3.3.jar:?] at ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:1230) ~[ognl-3.3.3.jar:?] at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1958) ~[ognl-3.3.3.jar:?] at ognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:68) ~[ognl-3.3.3.jar:?] at com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethodWithDebugInfo(XWorkMethodAccessor.java:98) ~[struts2-core-6.0.3.jar:6.0.3] at com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethod(XWorkMethodAccessor.java:90) ~[struts2-core-6.0.3.jar:6.0.3] pw is to send text output to the client in a servlet or other Java-based web application. eg: import java.io.PrintWriter; public PrintWriter pw = null; pw = response.getWriter(); Link to comment Share on other sites More sharing options...
lucianc Posted August 23 Share Posted August 23 You need to use Jaspersoft Studio 7 to convert your reports (*.jrxml files) to the JasperReports 7 syntax. Regards, Lucian Link to comment Share on other sites More sharing options...
Imz Posted August 26 Author Share Posted August 26 Already convert my .jrxml files to JasperReports 7 syntax, but same error occurred. Link to comment Share on other sites More sharing options...
Imz Posted August 26 Author Share Posted August 26 I have try to add *.jar from Jasper 7 library and can download the pdf but cant view it. Now got this error: Caused by: java.lang.NoClassDefFoundError: com/lowagie/text/pdf/FopGlyphProcessor I have try to add itextpdf-5.5.13.4.jar, but same issue occurred. Link to comment Share on other sites More sharing options...
lucianc Posted August 26 Share Posted August 26 You need OpenPDF 1.3.32 on your application's classpath. Link to comment Share on other sites More sharing options...
Imz Posted August 26 Author Share Posted August 26 Thank you so much! I changed from iText to OpenPDF, and now the PDF can be viewed. Link to comment Share on other sites More sharing options...
Imz Posted August 27 Author Share Posted August 27 I got issue when want to download XLS format, now there is no issue when download PDF and XLSX. Error occurred - Caused by: java.lang.ClassNotFoundException: net.sf.jasperreports.engine.export.JRXlsExporter at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1329) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1141) ... 128 more Do you have any idea about this? Link to comment Share on other sites More sharing options...
lucianc Posted August 27 Share Posted August 27 You need jasperreports-excel-poi-7.0.0.jar Link to comment Share on other sites More sharing options...
Imz Posted August 27 Author Share Posted August 27 Yes already add jasperreports-excel-poi-7.0.0.jar, its worked for XLSX but not for XLS. Link to comment Share on other sites More sharing options...
Imz Posted August 27 Author Share Posted August 27 1 hour ago, Imz said: Yes already add jasperreports-excel-poi-7.0.0.jar, its worked for XLSX but not for XLS. Also added jasperreports-excel-poi-7.0.0.jar, still not working. Link to comment Share on other sites More sharing options...
lucianc Posted August 27 Share Posted August 27 Have you also added the dependencies of jasperreports-excel-poi, such as POI 5.2.2? Link to comment Share on other sites More sharing options...
Imz Posted August 27 Author Share Posted August 27 Yes added, still error Link to comment Share on other sites More sharing options...
lucianc Posted August 27 Share Posted August 27 (edited) Please post the full exception stacktrace and the list of jars in your application. Edited August 27 by lucianc Link to comment Share on other sites More sharing options...
Imz Posted August 27 Author Share Posted August 27 It only show this exception: Caused by: java.lang.ClassNotFoundException: net.sf.jasperreports.engine.export.JRXlsExporter at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1329) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1141) ... 128 more List of jars: - commons-collections-3.2.2.jar - commons-collections4-4.4.jar - commons-csv-1.1.jar - commons-lang-2.6.jar - commons-lang3-3.10.jar - commons-logging-1.3.0.jar - jackson-annotations-2.17.1.jar - jackson-core-2.17.1.jar - jackson-databind-2.17.1.jar - jackson-dataformat-xml-2.17.1.jar - jakarta.activation-api-1.2.1.jar - jasperreports-7.0.0.jar - jasperreports-barbecue-7.0.0.jar - jasperreports-barcode4j-7.0.0.jar - jasperreports-chart-customizers-7.0.0.jar - jasperreports-charts-7.0.0.jar - jasperreports-chrome-7.0.0.jar - jasperreports-data-adapters-7.0.0.jar - jasperreports-data-adapters-http-7.0.0.jar - jasperreports-excel-poi-7.0.0.jar - jasperreports-fastexcel-7.0.0.jar - jasperreports-fonts-7.0.0.jar - jasperreports-google-maps-7.0.0.jar - jasperreports-javascript-7.0.0.jar - jasperreports-jdt-7.0.0.jar - jasperreports-json-7.0.0.jar - jasperreports-legacy-jrxml-core-7.0.0.jar - jasperreports-pdf-7.0.0.jar - metadata-extractor-2.19.0.jar - openpdf-2.0.3.jar - poi-5.2.2.jar - poi-ooxml-5.2.2.jar - xml-apis-ext-1.3.04.jar - xmlbeans-5.0.3.jar - xmlgraphics-commons-2.9.jar - xmlschema-core-2.2.5.jar - xmpcore-6.1.11.jar - xom-1.2.10.jar - xwork-core-2.3.35.jar I skipped some jars that I thought were not related. Link to comment Share on other sites More sharing options...
Solution Imz Posted August 28 Author Solution Share Posted August 28 It was a simple mistake on my part. I checked my program and noticed it was using import net.sf.jasperreports.engine.export.JRXlsExporter;. I changed it to import net.sf.jasperreports.poi.export.JRXlsExporter; and added SparseBitSet jar. It works now, and I can download .xls files. Thanks for your assistance! 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