英文:
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
-
"Caused by: java.lang.NullPointerException: 无法从短数组加载,因为'sun.awt.FontConfiguration.head'为null"
-
无法初始化类net.sf.jasperreports.engine.util.JRStyledTextParser。
尝试了以下解决方案,但都未成功:
- 首先尝试启用无头模式,但未解决问题。
- 添加了大多数依赖的可选JAR包用于Jasper 6.20.0,但未解决问题。
- 根据Java 17重新生成了报告的Jasper文件,但未帮助解决问题。
- 从扩展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
-
"Caused by: java.lang.NullPointerException: Cannot load from short array because "sun.awt.FontConfiguration.head" is null"
-
Could not initialize class net.sf.jasperreports.engine.util.JRStyledTextParser.
Tried on following resolutions but failed with them
- first tried to enable healess mode, but it did not resolve it
- most of the dependent optional jar for the Jasper 6.20.0 was aslo added but did not resolve it
- the jasper file for th report was regenerated based on the java 17 , but did not helped
- extracted the font from the extetion jar and added with the resources folder but it did not resolve
答案1
得分: 2
问题出在Java方面
我们通过从旧的JDK复制文件夹和文件来解决了它。
从JDK8/jre/lib复制:
- 文件fontconfig.bfc
- 文件夹fonts
到JDK17/lib
祝好,Jan V.
英文:
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.
答案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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论