4

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 :

  • CentOs 6.6 - Kernel 2.6.32-504.el6.x86_64
  • Java 1.7_79 (Sun)
  • JasperReport 6.2.2
  • Apache Tomcat 7.0.68

Same question that:

I tried these solutions without success.

Community
  • 1
  • 1
cactuschibre
  • 1,908
  • 2
  • 18
  • 36

3 Answers3

1

So here some checks to do :

  • Red Hat KB : https://access.redhat.com/solutions/1311113.
    VMWare KB : https://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2010240.
    Your environment should have X11 and/or graphic packages (fonts etc.) installed OR you have to run Java with -Djava.awt.headless=true option. With headless, your libraries needs to have fonts included (Default JasperReport font is Pictonic.ttf)
  • Clean your Tomcat Cache and don't do hot deployment. Some JasperReport versions have memory leaks with ThreadLocal uses in some classes. See for example http://community.jaspersoft.com/jasperreports-library/issues/4403-0
  • 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...

cactuschibre
  • 1,908
  • 2
  • 18
  • 36
1

I've faced the same issue on my development machine. Basically it was happened due to problem in application server (Apache tomcat)

Basically I've accidentally deleted the "temp" folder in server root. So jasper cant compile the report and proceed with the report generation.

Also temp folder space can make a huge damage to report generation process.

So check following items in the server

  1. Server space
  2. Missing folders in tomcat server
Chinthaka Dinadasa
  • 3,332
  • 2
  • 28
  • 33
0

I found the solution after hours. If you use bitnami docker compose file, you must volume the java folder. Reports are running with java 1.8_201 version. So you should download 1.8_201 and volume it your docker compose.

volumes:
  - 'jasperreports_data:/bitnami/jasperreports'
  - '/path/your/downloaded/java:/opt/bitnami/java'
Arda Ç.
  • 504
  • 5
  • 7