Could not initialize class net.sf.jasperreports.en

2019-01-24 02:12发布

I'm trying to display my reports on the browser , but I keep getting this error:

enter image description here

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 ?

16条回答
We Are One
2楼-- · 2019-01-24 02:17

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
查看更多
做自己的国王
3楼-- · 2019-01-24 02:18

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.

查看更多
萌系小妹纸
4楼-- · 2019-01-24 02:19

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)
查看更多
戒情不戒烟
5楼-- · 2019-01-24 02:20

You can try make a downgrade to jdk7, it's works to me.

sorry my english!

查看更多
该账号已被封号
6楼-- · 2019-01-24 02:22

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

查看更多
冷血范
7楼-- · 2019-01-24 02:25

this may be problems with memory, reboot the server.

查看更多
登录 后发表回答