giulius
giulius

Reputation: 409

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

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 ?

Upvotes: 1

Views: 11323

Answers (2)

giulius
giulius

Reputation: 409

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!

Upvotes: 1

Steven Lizarazo
Steven Lizarazo

Reputation: 5454

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

Upvotes: 2

Related Questions