I\'m trying to display my reports on the browser , but I keep getting this error:
This can as well be caused by missing/inaccessible Java 'temp' directory. In Font.java, temp files are being created:
Files.createTempFile("+~JF", ".tmp").toFile();
On one system, the 'temp' dir was missing under Tomcat folder but Java was configured to use it:
-Djava.io.tmpdir=C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0\temp
BTW. first time around, after restarting Tomcat, the service was actually throwing an IOException, but then JasperReports cached something and on subsequent calls the stack trace was exactly as reported here.
This seems like a Headless mode issue. You need to set the java.awt.headless
property to true
. That can be done using:
static {
System.setProperty("java.awt.headless", "true");
}
Or, by setting the headless property in your tomcat startup command as -Djava.awt.headless=true
Also, you can read more on why this is necessary, you can read about the Headless mode here
In my case problem was with the jdk8 which I was using to build docker image, but after some search I switched to jre. That fixed my bug. I think you can try any image rather than using jdk8.
This might help ,I had the same error and every other solution didn't work.
I fixed it by updating to java8.
I searched several hours for the same issue, and my solution is none of the others mentioned.
Due to a bad update of my jasper reports version I had multiple versions of the jasperreports jar file on my classpath. Make sure you only have a single jasperreports jar file...
In my case i was using Arial fonts for this i have configured arial fonts in irfonts.xml which was like below
<fontFamily name="Arial">
<normal><![CDATA[fonts/arial.ttf]]>
</normal>
<bold><![CDATA[fonts/arialbd.ttf]]>
</bold>
<italic><![CDATA[fonts/ariali.ttf]]>
</italic>
<boldItalic><![CDATA[fonts/arialbi.ttf]]>
</boldItalic>
<pdfEmbedded><![CDATA[true]]>
</pdfEmbedded></fontFamily>
but it should be like :
<fontFamily name="Arial">
<normal><![CDATA[fonts/arial.ttf]]><
/normal>
<bold><![CDATA[fonts/arialbd.ttf]]></bold>
<italic><![CDATA[fonts/ariali.ttf]]></italic>
<boldItalic><!
[CDATA[fonts/arialbi.ttf]]></boldItalic>
<pdfEmbedded><!
[CDATA[true]]></pdfEmbedded>
</fontFamily>
so their was a space before the end tag of each tag in above configuration file.
i fixed it by removing space between them.