I would like to share my experience with a more or less common error with JasperReports.
When executing JasperReports to make a PDF report, I have an exception :
java.lang.NoClassDefFoundError: Could not initialize class net.sf.jasperreports.engine.util.JRStyledTextParser
net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:108)
net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:69)
net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:57)
net.sf.jasperreports.engine.fill.JRFiller.createBandReportFiller(JRFiller.java:200)
net.sf.jasperreports.engine.fill.JRFiller.createReportFiller(JRFiller.java:215)
net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:115)
net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:667)
net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:983)
My environment :
Same question that:
I tried these solutions without success.
So here some checks to do :
-Djava.awt.headless=true
option. With headless, your libraries needs to have fonts included (Default JasperReport font is Pictonic.ttf)
JRStyledTextParser have a static initializer which can mask some exceptions. It especially initializes the loading of fonts (on the OS or included in jar) in a cache by using Font implement in java.awt. But, see the source code of Font :
private static boolean hasTempPermission() {
if (System.getSecurityManager() == null) {
return true;
}
File f = null;
boolean hasPerm = false;
try {
f = Files.createTempFile("+~JT", ".tmp").toFile();
f.delete();
f = null;
hasPerm = true;
} catch (Throwable t) {
/* inc. any kind of SecurityException */
}
return hasPerm;
}
Java create temp file (using java.io.tmp option if you have specified it). So check that your temporary folder is not full and writable by the user/group of Java PID. If it is not the case, an exception will be thrown, but catched and invisible...