Linux/Unix下JFreeChart的NoClassDefFoundError问题
程序员文章站
2024-01-23 18:47:28
...
最近遇到这样一个问题,使用JFreechart 1.0.13开发的程序,在Windows上正常运行,到Linux下就莫名其妙的报错了,查看log,出现了
Caused by: java.lang.NoClassDefFoundError
at org.jfree.chart.ChartFactory.createBarChart...
一般的出现NoClassDefFoundError,都是因为缺少Java Class的依赖,而且会提示缺少的Class名字,这个就比较怪了,这里我们看看如何处理这类的问题。
出错原因
Google一下
java.lang.NoClassDefFoundError
at org.jfree.chart.ChartFactory.createBarChart
发现在http://www.jfree.org/上很多人都有这个问题,而且都出现在Linux或者Unix系统上,原来这是一个Linux/Unix下Java的问题。详细见:http://www.jfree.org/phpBB2/viewtopic.php?t=8420
写道
-------------------------------------------------------------------------------
10. My web application runs fine on my Windows development machine, but when
I deploy it to the Unix/Linux production server, it doesn't work. What
is the problem?
Most likely your server does not have X11 running. This is a Java
(AWT/Java2D) issue, not something that is specific to JFreeChart. There is
some more information at Sun's website:
http://java.sun.com/products/java-media/2D/forDevelopers/java2dfaq.html#xvfb
In addition, the following thread in the JFreeChart forum contains some
useful information:
http://www.jfree.org/phpBB2/viewtopic.php?t=1012
-------------------------------------------------------------------------------
10. My web application runs fine on my Windows development machine, but when
I deploy it to the Unix/Linux production server, it doesn't work. What
is the problem?
Most likely your server does not have X11 running. This is a Java
(AWT/Java2D) issue, not something that is specific to JFreeChart. There is
some more information at Sun's website:
http://java.sun.com/products/java-media/2D/forDevelopers/java2dfaq.html#xvfb
In addition, the following thread in the JFreeChart forum contains some
useful information:
http://www.jfree.org/phpBB2/viewtopic.php?t=1012
-------------------------------------------------------------------------------
这里给出了问题的详细链接,以及解决方案。
解决方案
1,如果是Tomcat等Web server中的app,遇到这个问题,可以尝试修改tomcat的启动配置,添加如下的Java的参数:
-Djava.awt.headless = true
一般在%TomcatHome%\bin\catalina.bat文件中设置
set JAVA_OPTS=%JAVA_OPTS% -Djava.awt.headless = true
不过很可惜,测试没有作用,依然出错。可能是哪里出了问题。
2,在应用程序中添加Java属性设置:
System.setProperty("java.awt.headless","true")
测试生效!
本文同步发表在 http://www.xeclipse.com/?p=1287
推荐阅读
-
Linux/Unix下JFreeChart的NoClassDefFoundError问题
-
完美解决linux下vim在终端不能用鼠标复制的问题
-
linux下 PHP 7 Laravel 使用unique做validation的时候生成SQL语句有问题
-
Unix下配置Scheduler的过程及出现问题的解决
-
thinkpad e40 0578mdc linux下使用ThinkPHP需要注意大小写导致的问题
-
linux下使用ThinkPHP需要注意大小写导致的问题_PHP
-
RedHat Linux AS4下MySQL两个问题的处理
-
Linux下 Smarty中的display显示有关问题
-
yii2 - linux、mac下,php连接sql server的问题
-
linux下mysql的用户管理及访问问题_MySQL