Cannot load from short array because "sun.awt.FontConfiguration.head" is null thrown with Java 17 and Jasper 6.20.0

huangapple go评论101阅读模式
英文:

Cannot load from short array because "sun.awt.FontConfiguration.head" is null thrown with Java 17 and Jasper 6.20.0

问题

我们正在将我们的应用程序升级到Java 17(从Java 8),并升级Jasper到6.20.0(从6.0.3)。在这个升级过程中,Jasper报告出现了两个异常。

操作系统:red hat linux 7.9
Tomcat:jws 5.4(-Djava.awt.headless=true)
JDK:Oracle Java 17

  1. "Caused by: java.lang.NullPointerException: 无法从短数组加载,因为'sun.awt.FontConfiguration.head'为null"

  2. 无法初始化类net.sf.jasperreports.engine.util.JRStyledTextParser。

尝试了以下解决方案,但都未成功:

  1. 首先尝试启用无头模式,但未解决问题。
  2. 添加了大多数依赖的可选JAR包用于Jasper 6.20.0,但未解决问题。
  3. 根据Java 17重新生成了报告的Jasper文件,但未帮助解决问题。
  4. 从扩展JAR中提取了字体并添加到资源文件夹,但未解决问题。
英文:

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

答案1

得分: 2

问题出在Java方面 Cannot load from short array because "sun.awt.FontConfiguration.head" is null thrown with Java 17 and Jasper 6.20.0

我们通过从旧的JDK复制文件夹和文件来解决了它。

从JDK8/jre/lib复制:

  • 文件fontconfig.bfc
  • 文件夹fonts

到JDK17/lib

祝好,Jan V.

英文:

the problem is with Java Cannot load from short array because "sun.awt.FontConfiguration.head" is null thrown with Java 17 and Jasper 6.20.0

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.

答案2

得分: 0

安装fontconfig帮助我解决了这个错误。

只需运行命令sudo yum install fontconfig,然后重新启动应用程序服务器。错误就消失了。

英文:

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.

huangapple
  • 本文由 发表于 2023年5月29日 17:16:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/76356076.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定