http://blog.chinaunix.net/uid-25098298-id-287544.html
1. 什么是 java.awt.headless?
Headless模式是系统的一种配置模式。在该模式下,系统缺少了显示设备、键盘或鼠标。
2. 何时使用和headless mode?
Headless模式虽然不是我们愿意见到的,但事实上我们却常常需要在该模式下工作,尤其是服务器端程序开发者。因为服务器(如提供Web服务的主机)往往可能缺少前述设备,但又需要使用他们提供的功能,生成相应的数据,以提供给客户端(如浏览器所在的配有相关的显示设备、键盘和鼠标的主机)。
3. 如何使用和Headless mode?
一般是在程序开始激活headless模式,告诉程序,现在你要工作在Headless mode下,就不要指望硬件帮忙了,你得自力更生,依靠系统的计算能力模拟出这些特性来:
System.setProperty("java.awt.headless", "true");
4. 测试程序:
http://leshazlewood.com/2009/08/26/linux-javaawtheadless-and-the-display-environment-variable/
Just a quick note to self:
After looking at the JDK source code today, we found that even when setting -Djava.awt.headless=true
, if a script executes with the DISPLAY
environment variable set, the AWT graphics environment will still use a GraphicsEnvironment representing that DISPLAY
.
A major problem with this is if the shell that launched the script that started the java process ever executes, the GraphicsEnvironment reflecting the DISPLAY will be removed and any Object instances reflecting that environment would be invalidated or Classes once available will no longer be available. resulting in a NoClassDefFoundException.
Bottom line: on Linux, if setting -Djava.awt.headless=true
in a script, ensure that you unset DISPLAY
in the script before starting the java
process. It will save some headaches in debugging.
==============https://confluence.atlassian.com/plugins/viewsource/viewpagesrc.action?pageId=133693889
When attempting to use a Chart either with the Chart Plugin (JIRA 3.13) or the Pie Chart Gadget (4.0+), no output is rendered. Errors like the following appear in the logs:
2008-02-04 12:45:36,051 TP-Processor6 ERROR [500ErrorPage] Exception caught in 500 page /usr/local/java/jdk1.6.0_02/jre/lib/i386/xawt/libmawt.so: libXtst.so.6: cannot open shared object file: No such file or directory java.lang.UnsatisfiedLinkError: /usr/local/java/jdk1.6.0_02/jre/lib/i386/xawt/libmawt.so: libXtst.so.6: cannot open shared object file: No such file or directory at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1647) at java.lang.Runtime.load0(Runtime.java:770) at java.lang.System.load(System.java:1005) at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1668) at java.lang.Runtime.loadLibrary0(Runtime.java:823) at java.lang.System.loadLibrary(System.java:1030) at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50) at java.security.AccessController.doPrivileged(Native Method) at java.awt.Toolkit.loadLibraries(Toolkit.java:1594) at java.awt.Toolkit.<clinit>(Toolkit.java:1616) at java.awt.Color.<clinit>(Color.java:263) at com.atlassian.jira.ext.charting.jfreechart.ChartUtils.<clinit>(ChartUtils.java:45) at com.atlassian.jira.ext.charting.data.DataCollector.populatePieChart(DataCollector.java:669) at com.atlassian.jira.ext.charting.charts.singlefieldpie.SingleFieldPieChart.getViewHtml(SingleFieldPieChart.java:57) at com.atlassian.jira.ext.charting.charts.PortletSearchView.writeSearchResults(PortletSearchView.java:89) |
In addition, errors like the following appear:
2008-02-04 12:49:14,654 TP-Processor2 ERROR [webwork.dispatcher.ServletDispatcher] Could not execute action java.lang.NoClassDefFoundError: Could not initialize class com.atlassian.jira.ext.charting.jfreechart.ChartUtils at com.atlassian.jira.ext.charting.data.DataCollector.retrieveOrMakeSearchRequest(DataCollector.java:205) |
Charts that create custom graphics require X11 libraries and an X11 session to assist in creating their output.
|
|
|
{htmlcomment} Regular Expression: java.lang.NoClassDefFoundError: Could not initialize class com.atlassian.jira.ext.charting.jfreechart.ChartUtils http://support.atlassian.com/browse/JSP-19704 {htmlcomment} |