Could not initialize class org.jfree.chart.JFreeChart

本文介绍了解决在Linux服务器上运行Web-CAT时出现的图表显示异常问题。该问题是由于Java试图连接到由DISPLAY环境变量标识的X11显示但因权限不足而引发。文中提供了解决方案,包括移除Tomcat用户的DISPLAY环境变量设置,并向Tomcat启动参数中添加-Djava.awt.headless=true。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

On linux servers:Could not initialize class org.jfree.chart.JFreeChart

On linux servers, some people have reported a problem after a successful install, once their server is in use. They report that Web-CAT produces unexpected exceptions when you visit any pages that contain charts, such as those graphing student results. The Web-CAT exception page cites the following Java exception:

Error: java.lang.NoClassDefFoundError
Reason: Could not initialize class org.jfree.chart.JFreeChart

Or possibly:

Error: java.lang.NoClassDefFoundError
Reason: Could not initialize class sun.awt.X11GraphicsEnvironment

If this occurs, check the environment variables for the pseudo-user under which Tomcat is running. Check for any definition for the DISPLAY environment variable that is visible to Tomcat, an remove any such definitions.

This problem appears to be caused internally in Sun's AWT implementation, where Java is trying to connect to the X11 display identified by the DISPLAY environment variable, but the user id under which Tomcat is running does not have permission to connect (or there is no active DISPLAY). Removing the environment variable setting for the Tomcat user will fix this problem. You may also need to add -Djava.awt.headless=true to Tomcat's startup arguments as well.

 

eq:

 I did a ps -ef | grep headless command to look at how tomcat was started and I found that this was passed in instead (with an extra ? on the end):

-Djava.awt.headless=true?

if don't have it,we should:

export  CATALINA_OPTS="-Djava.awt.headless=true" 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值