font issue with jasperreport 5.2 vs jasperreport 5.5

i'am using jasperport engine with font extensions to generate a pdf file
for example: i'have done an Arial.jar from iReport and put it into the CLASSPATH.
than to generate the pdf i use an own small java class (from command line) with arguments:
- Data source (xml)
- File. Jasper report
- Name of the pdf
and pass them to the jasperreport engine
now with jasperreport 5.2 it works fine   (even in version 5.0 works fine)
while in the version 5.5 i get this error:
net.sf.jasperreports.engine.util.JRFontNotFoundException: Font 'Arial' is not available to the JVM. See the Javadoc for more details.
        at net.sf.jasperreports.engine.fonts.FontUtil.checkAwtFont(
        at net.sf.jasperreports.engine.fonts.FontUtil.getAwtFontFromBundles(
        at net.sf.jasperreports.engine.fill.SimpleTextLineWrapper.loadFont(
        at net.sf.jasperreports.engine.fill.SimpleTextLineWrapper.getGeneralFontInfo(
        at net.sf.jasperreports.engine.fill.SimpleTextLineWrapper.createFontInfo(
        at net.sf.jasperreports.engine.fill.SimpleTextLineWrapper.start(
        at net.sf.jasperreports.engine.fill.TextMeasurer.measure(
        at net.sf.jasperreports.engine.fill.JRFillTextElement.chopTextElement(
        at net.sf.jasperreports.engine.fill.JRFillStaticText.prepare(
        at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(
        at net.sf.jasperreports.engine.fill.JRFillBand.fill(
        at net.sf.jasperreports.engine.fill.JRFillBand.fill(
        at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(
        at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillGroupHeader(
        at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillGroupHeaders(
        at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(
        at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(
        at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(
        at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(
        at net.sf.jasperreports.engine.fill.JRFiller.fill(
        at net.sf.jasperreports.engine.JasperFillManager.fill(
        at net.sf.jasperreports.engine.JasperFillManager.fill(
        at net.sf.jasperreports.engine.JasperFillManager.fillReport(
there is some difference between the two version
about the fonts ?
many thanks
d.artini's picture
Joined: Nov 4 2013 - 3:23am
Last seen: 4 years 10 months ago

2 Answers:

it is related to the issue 3252 !


d.artini's picture
Joined: Nov 4 2013 - 3:23am
Last seen: 4 years 10 months ago

As Jaspersoft doesn't seem interested in answering this, even though it is clearly a bug within their software, I'll do my best to let people know what I've found with this and what i've managed to do to get it working (in my environment at least).

The crux of the problem appears to be that Jaspersoft Server 5.5 doesn't read the parameters for the font extensions if the values are enclosed in CDATA elements in their XML files. 5.2 did.

iReport (version 5.2 and 5.5) produces JAR archives that contain XML files with the parameter values enclodes in CDATA blocks.

Jaspersoft Studio 5.5 does not enclose values in CDATA blocks, however it has a different bug where it uses the absolute path to the font file on the local machine where the JAR font extension was created, instead of the relative path to the font file contained within the JAR archive.

Jaspersoft Studio 5.2 doesn't appear to be capable of creating a working JAR font extension at all.

In order to fix this you can edit the XML file within the JAR archive of the font extension (Hopefully you don't have too many font extensions...)

You can open the JAR archive using 7-Zip or soething similar, in there under the fonts directory, there'll be an XML file that needs to be modified (either using the in-built editor of your compression program or by extracting, editing, saving and replacing the file within the archive).

The contents of this file should look something like this (this is the file generated by iReport, which you should be working with, as Jaspersoft Studio doesn't, well, work properly at all) -

<?xml version="1.0" encoding="UTF-8"?>
   <fontFamily name="Herr Von Muellerhoff">

What you need to do, for each of the properties listed, is remove the surrounding CDATA blocks (so, "<![CDATA[" at the beginning and "]]>" at the end. The resulting file should look similar to this -

<?xml version="1.0" encoding="UTF-8"?>
   <fontFamily name="Herr Von Muellerhoff">

Save that file in place within the JAR archive and upload to you lib directory on the server (replacing the current font extension), and that should get you up and running again. At least it did for me.

cameron_1's picture
Joined: May 5 2013 - 8:32pm
Last seen: 6 years 2 months ago

Thanks cameron_1 thats a good find.

Exie - 9 years 9 months ago

Works like a charm!! Many thanks!

msjunior - 9 years 8 months ago

After searching for hours for a solution this post saved my day. Many thanks!

pnikits - 9 years 8 months ago
show 1 more...

You da Man!! Cameron!

Horrible support from jaspersoft.. shame on you.

jgosala - 9 years 3 months ago