1

We upgrading the our application to Java 17 (from Java 8) and Jasper to 6.20.0 (from 6.0.3). During this upgrade Jasper reports getting failed with the two exceptions. The fonts is already exported and used as an extension jar which was working fine with java 8 and jasper 6.0.3. But once the upgrade is done, following given exceptions occurs.

OS : red hat linux 7.9 tomcat : jws 5.4 (-Djava.awt.headless=true)
jdk : Oracle Java 17

  1. "Caused by: java.lang.NullPointerException: Cannot load from short array because "sun.awt.FontConfiguration.head" is null"

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

Tried on following resolutions but failed with them

  1. first tried to enable healess mode, but it did not resolve it
  2. most of the dependent optional jar for the Jasper 6.20.0 was aslo added but did not resolve it
  3. the jasper file for th report was regenerated based on the java 17 , but did not helped
  4. extracted the font from the extetion jar and added with the resources folder but it did not resolve
Madhawa
  • 11
  • 3
  • Installing the fonts packages helped me, when running on alpine. Particularly: `apk add --no-cache msttcorefonts-installer fontconfig && update-ms-fonts`. See: https://stackoverflow.com/a/74978195/4457564 The names of the packages might be a bit different on Red Hat Linux – Ewa Jul 25 '23 at 00:13

2 Answers2

2

the problem is with Java :)

We solved it, by copying the folder and file from the old JDK.

Make copy from JDK8/jre/lib :

  • file fontconfig.bfc
  • folder fonts

To JDK17/lib

BR Jan V.

0

Install fontconfig helped me to solve the error.

https://yum-info.contradodigital.com/view-package/base/fontconfig/

just run command sudo yum install fontconfig and restart the application server. The error is gone.

Ndrik7
  • 103
  • 13