Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not initialize class net.sf.jasperreports.engine.util.JRStyledTextParser

I'm trying to display my reports on the browser , but I keep getting this error:

enter image description here

the strange thing about this, is that it only happens when I attempt to generate the reports from the version installed on the server, but not when I do it locally from my pc

Have you any idea why this is happening ?

like image 356
eddy Avatar asked Feb 15 '11 00:02

eddy


3 Answers

For those still running into this issue: on Ubuntu Server 12.04 with headless OpenJDK JRE, it was simply solved by

apt-get install ttf-dejavu-extra
like image 59
zwets Avatar answered Nov 06 '22 14:11

zwets


This seems like a Headless mode issue. You need to set the java.awt.headless property to true. That can be done using:

static {
    System.setProperty("java.awt.headless", "true");
}

Or, by setting the headless property in your tomcat startup command as -Djava.awt.headless=true

Also, you can read more on why this is necessary, you can read about the Headless mode here

like image 31
Master.Aurora Avatar answered Nov 06 '22 14:11

Master.Aurora


For me the issue was regarding a bug in AdoptOpenJDK: https://github.com/AdoptOpenJDK/openjdk-build/issues/682

I fixed the issue by installing ttf-dejavu manually in my dockerfile

FROM adoptopenjdk/openjdk8:alpine-jre

# Workaround for wrong font configuration in adoptopenjdk
# https://github.com/AdoptOpenJDK/openjdk-build/issues/682
RUN apk update && apk upgrade \
   && apk add --no-cache ttf-dejavu \
   # Install windows fonts as well. Not required..
   && apk add --no-cache msttcorefonts-installer \
   && update-ms-fonts && fc-cache -f

AND by running the application with the flag -Djava.awt.headless=true

like image 9
Mr.Turtle Avatar answered Nov 06 '22 15:11

Mr.Turtle