问题描述

在Jira 7.13 以后的版本,如果缺少字体会出现 FontConfiguration error 的错误, 此类错误可能在以下情况出现

  • 安装Jira的时候
  • 查看项目报告 Project Reports


019-01-03 15:36:11,699 http-nio-8898-exec-4 ERROR      [o.a.c.c.C.[.[localhost].[/sd4_obr_eap08].[action]] Servlet.service() for servlet [action] in context with path [/sd4_obr_eap08] threw exception [java.lang.NullPointerException] with root cause
java.lang.NullPointerException
	at sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1264)
	at sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:219)
	at sun.awt.FontConfiguration.init(FontConfiguration.java:107)
	at sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:774)
	at sun.font.SunFontManager$2.run(SunFontManager.java:431)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.font.SunFontManager.<init>(SunFontManager.java:376)
	at sun.awt.FcFontManager.<init>(FcFontManager.java:35)
	at sun.awt.X11FontManager.<init>(X11FontManager.java:57)
	... 3 filtered
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at java.lang.Class.newInstance(Class.java:442)
	at sun.font.FontManagerFactory$1.run(FontManagerFactory.java:83)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74)
	at java.awt.Font.getFont2D(Font.java:491)
	at java.awt.Font.defaultLineMetrics(Font.java:2176)
	at java.awt.Font.getLineMetrics(Font.java:2246)
	at org.jfree.chart.axis.NumberAxis.estimateMaximumTickLabelHeight(NumberAxis.java:966)
	at org.jfree.chart.axis.NumberAxis.selectVerticalAutoTickUnit(NumberAxis.java:1095)
	at org.jfree.chart.axis.NumberAxis.selectAutoTickUnit(NumberAxis.java:1040)
	at org.jfree.chart.axis.NumberAxis.refreshTicksVertical(NumberAxis.java:1261)
	at org.jfree.chart.axis.NumberAxis.refreshTicks(NumberAxis.java:1140)
	at org.jfree.chart.axis.ValueAxis.reserveSpace(ValueAxis.java:807)
	at org.jfree.chart.plot.XYPlot.calculateRangeAxisSpace(XYPlot.java:3117)
	at org.jfree.chart.plot.XYPlot.calculateAxisSpace(XYPlot.java:3026)
	at org.jfree.chart.plot.XYPlot.draw(XYPlot.java:3156)
	at org.jfree.chart.JFreeChart.draw(JFreeChart.java:1235)
	at org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1409)
	at org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1389)
	at com.atlassian.jira.charts.jfreechart.ChartHelper.createChartImageInline(ChartHelper.java:126)
	at com.atlassian.jira.charts.jfreechart.ChartHelper.generateInline(ChartHelper.java:85)
	at com.atlassian.jira.charts.AverageAgeChart.generateChartInternal(AverageAgeChart.java:91)
	at com.atlassian.jira.charts.AverageAgeChart.generateInlineChart(AverageAgeChart.java:64)
	at com.atlassian.jira.charts.DefaultChartFactory.generateAverageAgeChart(DefaultChartFactory.java:98)
	... 2 filtered
	at java.lang.reflect.Method.invoke(Method.java:498)
CODE


原因分析

因为Jira 7.13之后使用了Open JDK 替换了原来的Oracle JDK, 在 AdoptOpenJDJ中并买有包含字体配置包,如果您的操作系统中也缺少字体配置包, 就会导致上述问题


解决方法

安装字体配置包

buntu 


sudo apt install -y fontconfig

CentOS 7


sudo yum install -y dejavu-sans-fonts

CentOS 6

sudo yum install -y fontconfig dejavu-sans-fonts

RHEL 


sudo yum install fontconfig

Debian 


apt-get update && apt-get install -y fontconfig

Fedora


dnf install -y fontconfig



使用Atlassian提供的脚本安装