可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I'm trying to display my reports on the browser , but I keep getting this error:
the strange thing about this, is that it only happens when I attempt to generate the reports from the version installed on the server, but not when I do it locally from my pc
Have you any idea why this is happening ?
回答1:
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.
回答2:
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
回答3:
This is a missing jars in the class path issue.
I had this issue and found that with by adding the missing jars to the class path it resolved the issue.
From the below article
java.dzone.com article
I found that the minimal jars necessary are...Now The versions numbers have changed but with these libraries only I managed to get it working.
- jasperreports-2.0.4.jar
- commons-digester-1.7.jar
- commons-collections-2.1.jar (commons-collections.jar)
- commons-logging-1.0.2.jar
- commons-beanutils.jar
- iText-2.0.7.jar (used infor PDF exporting)
回答4:
For those still running into this issue: on Ubuntu Server 12.04 with headless OpenJDK JRE, it was simply solved by
apt-get install ttf-dejavu-extra
回答5:
To resolve the issue, do the following:
- Switched from Open JDK to Sun JDK
- Installed MS Core Fonts
- Packaged JasperReport font library jar with the application
回答6:
this may be problems with memory, reboot the server.
回答7:
I got this error while deploying springboot app (including jasper reporting) in docker container.The problem was with openjdk:8-jdk-alpine which I used for building docker container environment. That has a bug in fonts support. Therefore I switched to openjdk:8-jre (or OpenJDK 7 versions will also help) and it worked for me. I spent days to fix this bug.
回答8:
A little late, but here is why we had this problem... We recently started developing with IntelliJ instead of Eclipse. We simply forgot to run IntelliJ as administrator... We had done this with Eclipse for a long time already, but simply didn't think about it with IntelliJ.
In the end, I guess the fonts weren't found or a folder was not found since there were insufficient rights to read/write on the c drive.
回答9:
Got the same error - apparently JRStyledTextParser is using dependency from xml-apis
By adding xml-apis I got it fixed
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>
回答10:
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.
回答11:
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...
回答12:
This might help ,I had the same error and every other solution didn't work.
I fixed it by updating to java8.
回答13:
In our case it helped to delete the temp server (thus making sure there are no jar duplicities) and restart server.
Hint: try this in case if the error starts occurring after a new release (but worked before and nothing relevant changed in the release)
回答14:
I've faced the same issue on my development machine. Basically it was happened due to problem in application server (Apache tomcat)
Basically I've accidentally deleted the "temp" folder in server root. So jasper cant compile the report and proceed with the report generation.
回答15:
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.
回答16:
You can try make a downgrade to jdk7, it's works to me.
sorry my english!