Linux下webLogic无法使用jasperreports(iReport)生成报表的问题解决方法

今天在Linux下的webLogic部署一个项目后,发现报表无法导出了(但是在Windows开发环境下正常),后台报错如下:

java.lang.InternalError: Can´t connect to X11 window server using ´:0.0´ as the value of the DISPLAY variable.
        at sun.awt.X11GraphicsEnvironment.initDisplay()V(X11GraphicsEnvironment.java:???)
        at sun.awt.X11GraphicsEnvironment.<clinit>()V(X11GraphicsEnvironment.java:134)
        at jrockit.vm.Classes.forName0(Ljava.lang.String;ZI)I(Unknown Source)
        at jrockit.vm.Classes.forName(Ljava.lang.String;ZLjava.lang.ClassLoader;)Ljava.lang.Class;(Unknown Source)
        at java.lang.Class.forName(Ljava.lang.String;I)Ljava.lang.Class;(Unknown Source)
        at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment()Ljava.awt.GraphicsEnvironment;(GraphicsEnvironment.java:62)
        at net.sf.jasperreports.engine.util.JRGraphEnvInitializer.initializeGraphEnv()V(JRGraphEnvInitializer.java:58)
        at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(Lnet.sf.jasperreports.engine.JasperReport;Lnet.sf.jasperreports.engine.fill.JREvaluator;Lnet.sf.jasperreports.engine.fill.JRBaseFiller;)V(JRBaseFiller.java:307)
        at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(Lnet.sf.jasperreports.engine.JasperReport;Lnet.sf.jasperreports.engine.fill.JREvaluator;Lnet.sf.jasperreports.engine.fill.JRBaseFiller;)V(JRVerticalFiller.java:92)
        at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(Lnet.sf.jasperreports.engine.JasperReport;)V(JRVerticalFiller.java:74)
        at net.sf.jasperreports.engine.fill.JRFiller.createFiller(Lnet.sf.jasperreports.engine.JasperReport;)Lnet.sf.jasperreports.engine.fill.JRBaseFiller;(JRFiller.java:147)
        at net.sf.jasperreports.engine.fill.JRFiller.fillReport(Lnet.sf.jasperreports.engine.JasperReport;Ljava.util.Map;Lnet.sf.jasperreports.engine.JRDataSource;)Lnet.sf.jasperreports.engine.JasperPrint;(JRFiller.java:83)
        at net.sf.jasperreports.engine.JasperFillManager.fillReport(Lnet.sf.jasperreports.engine.JasperReport;Ljava.util.Map;Lnet.sf.jasperreports.engine.JRDataSource;)Lnet.sf.jasperreports.engine.JasperPrint;(JasperFillManager.java:601)
 ...

经过左问Baidu,右问Google,加上验证得到Debug方法如下:

在startWebLogic.sh中加一行:JAVA_OPTIONS = -Djava.awt.headless=true
如果已有JAVA_OPTIONS配置行,则可以追加
-Djava.awt.headless=true

重启webLogic,问题解决!