JasperFillManager.fillReport()方法抛出java.io.Exception [英] The method JasperFillManager.fillReport () throws java.io.Exception
问题描述
当我在开发环境(SunOS 5.10 i86pc Solaris)中启动我的脚本时,我有以下异常,我尝试在谷歌搜索数小时尝试各种解决方法,但没有解决问题。
实际上,在我启动脚本时尝试使用超级用户生成报告,而对于普通用户,我得到以下异常并且不生成报告。
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.
引起:net.sf.jasperreports.engine.JRRuntimeException:java.io.IOException:读取字体数据时出错。
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)net.sf.jasperreports.engine.fonts.FontExtensionsRegistry.g
etExtensions(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更多
引起:java.io.IOException:读取字体数据时出现问题。
at java.awt.Font.createFont(Font.java:967)
at net.sf.jasperreports.engine.fonts.SimpleFontFace。< init>(SimpleFontFace.java:100)
... 50多
我注意到文件被写入临时文件夹(/ var / tmp)了权限设置为600,如何在Jasper Report中设置这些文件必须的权限?或者我应该重新检查/ bin / java的权限吗?
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 ?
推荐答案
我发现库可以避免在每个运行时编译你调用genarazione PDF的方法,直接用数据填充file.jasper。使用的代码片段如下:
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!
这篇关于JasperFillManager.fillReport()方法抛出java.io.Exception的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!