我遇到了一个我无法解决的奇怪问题。每当我尝试在CentOS机器上的应用服务器上从jrxml渲染PDF时,我都会收到“java.io.IOException:读取字体数据的问题”。报告是使用Jaspersoft Studio 5.6.0生成的。我怀疑它甚至不是字体相关的,因为在使用没有任何字体的报告时结果是相同的。
在Windows和Ubuntu 12.04上运行正常。
Caused by: java.lang.ExceptionInInitializerError
at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:124) [jasperreports-5.6.0.jar:5.6.0]
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:89) [jasperreports-5.6.0.jar:5.6.0]
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:104) [jasperreports-5.6.0.jar:5.6.0]
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:62) [jasperreports-5.6.0.jar:5.6.0]
at net.sf.jasperreports.engine.fill.JRFiller.createFiller(JRFiller.java:179) [jasperreports-5.6.0.jar:5.6.0]
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:108) [jasperreports-5.6.0.jar:5.6.0]
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:668) [jasperreports-5.6.0.jar:5.6.0]
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:984) [jasperreports-5.6.0.jar:5.6.0]
at org.springframework.web.servlet.view.jasperreports.AbstractJasperReportsView.fillReport(AbstractJasperReportsView.java:676) [spring-webmvc-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.web.servlet.view.jasperreports.AbstractJasperReportsView.renderMergedOutputModel(AbstractJasperReportsView.java:561) [spring-webmvc-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:267) [spring-webmvc-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1217) [spring-webmvc-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1005) [spring-webmvc-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:952) [spring-webmvc-4.0.3.RELEASE.jar:4.0.3.RELEASE]
... 71 more
Caused by: net.sf.jasperreports.engine.JRRuntimeException: java.io.IOException: Problem reading font data.
at net.sf.jasperreports.engine.fonts.SimpleFontFace.setTtf(SimpleFontFace.java:182) [jasperreports-5.6.0.jar:5.6.0]
at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.parseFontFace(SimpleFontExtensionHelper.java:368) [jasperreports-5.6.0.jar:5.6.0]
at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.parseFontFamily(SimpleFontExtensionHelper.java:290) [jasperreports-5.6.0.jar:5.6.0]
at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.parseFontFamilies(SimpleFontExtensionHelper.java:254) [jasperreports-5.6.0.jar:5.6.0]
at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.loadFontFamilies(SimpleFontExtensionHelper.java:215) [jasperreports-5.6.0.jar:5.6.0]
at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.loadFontFamilies(SimpleFontExtensionHelper.java:184) [jasperreports-5.6.0.jar:5.6.0]
at net.sf.jasperreports.engine.fonts.FontExtensionsRegistry.getExtensions(FontExtensionsRegistry.java:56) [jasperreports-5.6.0.jar:5.6.0]
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.getExtensions(DefaultExtensionsRegistry.java:110) [jasperreports-5.6.0.jar:5.6.0]
at net.sf.jasperreports.engine.util.JRStyledTextParser.<clinit>(JRStyledTextParser.java:83) [jasperreports-5.6.0.jar:5.6.0]
... 85 more
Caused by: java.io.IOException: Problem reading font data.
at java.awt.Font.createFont0(Font.java:1000) [rt.jar:1.8.0_05]
at java.awt.Font.createFont(Font.java:877) [rt.jar:1.8.0_05]
at net.sf.jasperreports.engine.fonts.SimpleFontFace.setTtf(SimpleFontFace.java:174) [jasperreports-5.6.0.jar:5.6.0]
... 93 more
DEBUG [org.jboss.as.config] (MSC service thread 1-2) Configured system properties:
[Standalone] =
awt.toolkit = sun.awt.X11.XToolkit
file.encoding = UTF-8
file.encoding.pkg = sun.io
file.separator = /
java.awt.graphicsenv = sun.awt.X11GraphicsEnvironment
java.awt.headless = true
java.awt.printerjob = sun.print.PSPrinterJob
java.class.path = /usr/share/wildfly-8.1.0.Final/jboss-modules.jar
java.class.version = 52.0
java.endorsed.dirs = /opt/jdk1.8.0_05/jre/lib/endorsed
java.ext.dirs = /opt/jdk1.8.0_05/jre/lib/ext:/usr/java/packages/lib/ext
java.home = /opt/jdk1.8.0_05/jre
java.io.tmpdir = /tmp
java.library.path = /usr/java/packages/lib/i386:/lib:/usr/lib
java.net.preferIPv4Stack = true
java.runtime.name = Java(TM) SE Runtime Environment
java.runtime.version = 1.8.0_05-b13
java.specification.name = Java Platform API Specification
java.specification.vendor = Oracle Corporation
java.specification.version = 1.8
java.util.logging.manager = org.jboss.logmanager.LogManager
java.vendor = Oracle Corporation
java.vendor.url = http://java.oracle.com/
java.vendor.url.bug = http://bugreport.sun.com/bugreport/
java.version = 1.8.0_05
java.vm.info = mixed mode
java.vm.name = Java HotSpot(TM) Server VM
java.vm.specification.name = Java Virtual Machine Specification
java.vm.specification.vendor = Oracle Corporation
java.vm.specification.version = 1.8
java.vm.vendor = Oracle Corporation
java.vm.version = 25.5-b02
javax.management.builder.initial = org.jboss.as.jmx.PluggableMBeanServerBuilder
javax.xml.datatype.DatatypeFactory = __redirected.__DatatypeFactory
javax.xml.parsers.DocumentBuilderFactory = __redirected.__DocumentBuilderFactory
javax.xml.parsers.SAXParserFactory = __redirected.__SAXParserFactory
javax.xml.stream.XMLEventFactory = __redirected.__XMLEventFactory
javax.xml.stream.XMLInputFactory = __redirected.__XMLInputFactory
javax.xml.stream.XMLOutputFactory = __redirected.__XMLOutputFactory
javax.xml.transform.TransformerFactory = __redirected.__TransformerFactory
javax.xml.validation.SchemaFactory:http://www.w3.org/2001/XMLSchema = __redirected.__SchemaFactory
javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom = __redirected.__XPathFactory
jboss.home.dir = /usr/share/wildfly-8.1.0.Final
jboss.host.name = medius-doc-verifier
jboss.modules.dir = /usr/share/wildfly-8.1.0.Final/modules
jboss.modules.system.pkgs = org.jboss.byteman
jboss.node.name = medius-doc-verifier
jboss.qualified.host.name = medius-doc-verifier.medius
jboss.server.base.dir = /usr/share/wildfly-8.1.0.Final/standalone
jboss.server.config.dir = /usr/share/wildfly-8.1.0.Final/standalone/configuration
jboss.server.data.dir = /usr/share/wildfly-8.1.0.Final/standalone/data
jboss.server.deploy.dir = /usr/share/wildfly-8.1.0.Final/standalone/data/content
jboss.server.log.dir = /usr/share/wildfly-8.1.0.Final/standalone/log
jboss.server.name = medius-doc-verifier
jboss.server.persist.config = true
jboss.server.temp.dir = /usr/share/wildfly-8.1.0.Final/standalone/tmp
line.separator =
logging.configuration = file:/usr/share/wildfly-8.1.0.Final/standalone/configuration/logging.properties
module.path = /usr/share/wildfly-8.1.0.Final/modules
org.jboss.boot.log.file = /usr/share/wildfly-8.1.0.Final/standalone/log/server.log
org.jboss.resolver.warning = true
org.xml.sax.driver = __redirected.__XMLReaderFactory
os.arch = i386
os.name = Linux
os.version = 2.6.32-431.el6.x86_64
path.separator = :
sun.arch.data.model = 32
sun.boot.class.path = /opt/jdk1.8.0_05/jre/lib/resources.jar:/opt/jdk1.8.0_05/jre/lib/rt.jar:/opt/jdk1.8.0_05/jre/lib/sunrsasign.jar:/opt/jdk1.8.0_05/jre/lib/jsse.jar:/opt/jdk1.8.0_05/jre/lib/jce.jar:/opt/jdk1.8.0_05/jre/lib/charsets.jar:/opt/jdk1.8.0_05/jre/lib/jfr.jar:/opt/jdk1.8.0_05/jre/classes
sun.boot.library.path = /opt/jdk1.8.0_05/jre/lib/i386
sun.cpu.endian = little
sun.cpu.isalist =
sun.io.unicode.encoding = UnicodeLittle
sun.java.command = /usr/share/wildfly-8.1.0.Final/jboss-modules.jar -mp /usr/share/wildfly-8.1.0.Final/modules org.jboss.as.standalone -Djboss.home.dir=/usr/share/wildfly-8.1.0.Final -Djboss.server.base.dir=/usr/share/wildfly-8.1.0.Final/standalone -Djava.awt.headless=true
sun.java.launcher = SUN_STANDARD
sun.jnu.encoding = UTF-8
sun.management.compiler = HotSpot Tiered Compilers
sun.os.patch.level = unknown
user.country = US
user.dir = /usr/share/wildfly-8.1.0.Final/bin
user.home = /root
user.language = en
user.name = root
user.timezone = Europe/Sarajevo
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version last-->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Invoice" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="40" bottomMargin="20" isSummaryWithPageHeaderAndFooter="true" whenResourceMissingType="Empty" uuid="4eedbb89-b4f6-4469-9ab6-f642a1688cf7">
<property name="com.jaspersoft.studio.unit." value="pixel"/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="InvoiceTestDataSourceProvider"/>
<import value="org.apache.commons.lang3.StringUtils"/>
<style name="Table_TD" mode="Transparent" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</style>
<style name="Table 1_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table 1_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table 1_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<parameter name="DATEFORMAT_PATTERN" class="java.lang.String" isForPrompting="false">
<parameterDescription><![CDATA[Date format for current user]]></parameterDescription>
<defaultValueExpression><![CDATA["MM/dd/yyyy"]]></defaultValueExpression>
</parameter>
<pageHeader>
<band height="266">
<image hAlign="Left">
<reportElement x="0" y="0" width="110" height="25" uuid="52b7fe13-c5ea-4ab8-9335-a57e5d481642"/>
<imageExpression><![CDATA["reports/logo.png"]]></imageExpression>
</image>
</band>
</pageHeader>
<detail>
<band height="275"/>
</detail>
<pageFooter>
<band height="71"/>
</pageFooter>
<summary>
<band height="102"/>
</summary>
</jasperReport>
如果您遇到过类似问题的任何帮助或信息,我们将不胜感激!
谢谢!
在抛出异常之前在CentOS上调试输出:
ESC[0mESC[32m13:41:21,228 DEBUG [net.sf.jasperreports.extensions.SpringExtensionsRegistry] (default task-28) Found 0 beans for extension type interface net.sf.jasperreports.repo.RepositoryService
ESC[0mESC[32m13:41:21,233 DEBUG [net.sf.jasperreports.extensions.SpringExtensionsRegistry] (default task-28) Found 0 beans for extension type interface net.sf.jasperreports.repo.PersistenceServiceFactory
在Windows机器上,还有两个额外的调试行,这些调试行在CentOS日志中不存在:
15:48:19,180 DEBUG [net.sf.jasperreports.extensions.SpringExtensionsRegistry] (default task-4) Found 7 beans for extension type interface net.sf.jasperreports.engine.fonts.FontFamily
15:48:19,182 DEBUG [net.sf.jasperreports.extensions.SpringExtensionsRegistry] (default task-4) Getting bean fontBean133462384309185621 as extension of type net.sf.jasperreports.engine.fonts.FontFamily
15:48:19,195 DEBUG [net.sf.jasperreports.extensions.SpringExtensionsRegistry] (default task-4) Found 0 beans for extension type interface net.sf.jasperreports.repo.RepositoryService
15:48:19,199 DEBUG [net.sf.jasperreports.extensions.SpringExtensionsRegistry] (default task-4) Found 0 beans for extension type interface net.sf.jasperreports.repo.PersistenceServiceFactory
答案 0 :(得分:0)
看起来有人遇到了similar issue with Jenkins。你试过用yum安装字体吗?
yum install dejavu-sans-fonts
在我的一个CentOS盒子上运行它不会引入任何X依赖。
修改:您的问题可能是由文件系统权限问题引起的。 This person reported a very similar issue由Java临时目录的错误权限引起。