The method JasperFillManager.fillReport () throws java.io.Exception

巧了我就是萌 提交于 2020-01-14 06:08:05

问题


I have the following exception when I launch my script in the development environment (SunOS 5.10 i86pc Solaris), I tried searching on google for hours trying various workarounds suggested but do not solve the problem. In fact, trying to use super-user when I launch my script the report is generated, whereas with a normal user I get the following exception and the report is not generated.

Caused by: net.sf.jasperreports.engine.JRRuntimeException: java.io.IOException: Problem reading font data. at net.sf.jasperreports.engine.fonts.SimpleFontFace.<init>(SimpleFontFace.java:108) at net.sf.jasperreports.engine.fonts.SimpleFontFace.<init>(SimpleFontFace.java:128) at net.sf.jasperreports.engine.fonts.SimpleFontFace.getInstance(SimpleFontFace.java:67) at net.sf.jasperreports.engine.fonts.SimpleFontFamily.setNormal(SimpleFontFamily.java:99) at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.parseFontFamily(SimpleFontExtensionHelper.java:261) at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.parseFontFamilies(SimpleFontExtensionHelper.java:232) at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.loadFontFamilies(SimpleFontExtensionHelper.java:193) at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.loadFontFamilies(SimpleFontExtensionHelper.java:162) at net.sf.jasperreports.engine.fonts.FontExtensionsRegistry.getExtensions(FontExtensionsRegistry.java:56) at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.getExtensions(DefaultExtensionsRegistry.java:110) at net.sf.jasperreports.engine.util.JRStyledTextParser.<clinit>(JRStyledTextParser.java:83) ... 40 more Caused by: java.io.IOException: Problem reading font data. at java.awt.Font.createFont(Font.java:967) at net.sf.jasperreports.engine.fonts.SimpleFontFace.<init>(SimpleFontFace.java:100) ... 50 more

I noticed that the file is written to the temporary folder (/var/tmp) has permissions set to 600, how can I set the permissions in Jasper Report that these files must be?? Or should I re-check the permissions of / bin / java ?


回答1:


In some cases the cause is the running instance not being able to write to the Java temp directory (java.io.tmpdir).

If your are running it on tomcat maybe you deleted the temp directory of the tomcat installation, or the folder have wrong permissions.

(tomcat folder)/temp




回答2:


I discovered that the library can avoid compiling at runtime each time you invoke the method for genarazione PDF, filling the file.jasper directly with the data. The code fragment used is the following:

FileInputStream fis = new FileInputStream("<NAME OF FILE.JASPER>"); 
BufferedInputStream bufferedInputStream = new BufferedInputStream(fis);
//Load bufferedInputStream file.jasper 
jasperReport = (JasperReport) JRLoader.loadObject(bufferedInputStream); 
jasperPrint = JasperFillManager.fillReport(jasperReport,parameters,new JRBeanArrayDataSource(arrlist));
JasperExportManager.exportReportToPdfFile(jasperPrint,"<NAME OF OUTPUT FILE>");

In this way it bypasses the problem!



来源:https://stackoverflow.com/questions/19386274/the-method-jasperfillmanager-fillreport-throws-java-io-exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!